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 ?
Ex开发者_如何学编程emple:
[self.navigationItem.rightBarButtonItem.accessToMySegmentedControl setEnabled:NO ...];
Cheers mates,
Gauthier
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.
精彩评论