开发者

- Update a UISegmentedControl of a UITabBarItem -

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜