Reputation: 41
Hi all i have a segmented control in my app. I want to hide that control on a specific condition. i tried to hide as we do it for a normal button. Create an outlet and using set Hidden property.But there is no such property for a segmented control So is there a way by which we can hide a segmented control ? Thanks in advance.
Upvotes: 0
Views: 85
Reputation: 5967
Creating NSSegmentedControl from code or IB doesn't affect any of the properties. The properties usage is same in both case.
Make sure you have connected the segmentControlInstance from InterfaceBuilder to the related pointer in code.
UIButton and UISegmentedControl both inherit from UIControl which in tern is inherited from UIView. The UIView has setHidden method which definitely works for the instances of UIButton & UISegmentedControl.
Suppose you have your Segment Control visible.
[segCtrl setHidden:NO];
if (specific condition) [segCtrl setHidden:YES];
This will certainly work in normal cases.
Upvotes: 0
Reputation: 15015
You can use setHidden
property for NSSegmentedControl
like that below:-
(if someCondition)?[self.segCntrl setHidden:NO]:[self.segCntrl setHidden:YES];
Note:- NSSegmentedControl
and NSButton
both inherited from NSControl
which further inherited from NSView
. So there is property of NSView
if you look into the class of NSView.h
inside Appkit Framework
.
Upvotes: 3