Jenix Abraham
Jenix Abraham

Reputation: 41

Hiding a segemented control in Cocoa

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

Answers (2)

Sanjay Mohnani
Sanjay Mohnani

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

Hussain Shabbir
Hussain Shabbir

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

Related Questions