开发者

- Update a UISegmentedControl of a UITabBarItem -

开发者 https://www.devze.com 2022-12-21 15:16 出处:网络
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 ?

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

精彩评论

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