tags:

views:

41

answers:

1

Hey guys,

I found out that I couldn't do it but just to make sure, would it be possible to disable one of the button of my segmentedcontrol without re-creating the whole thing ?

Exemple:

[self.navigationItem.rightBarButtonItem.accessToMySegmentedControl setEnabled:NO ...];

Cheers mates,

Gauthier

A: 

Keep a reference to the segmented control in your controller like this:

Foo.h

@interface Foo : UIViewController {
    UISegmentedControl *segmentedControl;
}

Foo.m

segmentedControl = [[UISegmentedControl alloc] initWithItems:items];
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;

UIBarButtonItem *bar = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl];
[self.navigationItem setRightBarButtonItem:bar];
[bar release];

Then you can always use segmentedControl to access your segmented control.

Can Berk Güder
Well done ;)Really easy but I wouldn't have thought about it :DThanks.
gotye