我创建了一个自定义右视图,如下所示:
// Build the Segmented Control
NSArray *segmentTextContent = [NSArray arrayWithObjects:[UIImage imageNamed:@"arrow-dice.png"], [UIImage imageNamed:@"arrow-up.png"], [UIImage imageNamed:@"arrow-down.png"], nil];
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:segmentTextContent];
// Customize the Segmented Control
segmentedControl.momentary = YES;
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
[segmentedControl addTarget:self action:@selector(segmentChanged:) forControlEvents:UIControlEventValueChanged];
然后我将它添加到我的导航栏,如下所示:
// Add the control to the navigation bar right item
UIBarButtonItem *segmentItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl];
[segmentedControl release];
self.navigationItem.rightBarButtonItem = segmentItem;
self.navigationItem.rightBarButtonItem.title = @"";
[segmentItem release];
我可以按如下方式隐藏它:
self.navigationItem.rightBarButtonItem.customView.hidden = NO;
问题 ...但是如何禁用分段控件的所有(或更好的特定元素)?
以下不起作用。
self.navigationItem.rightBarButtonItem.enabled = NO;
任何想法表示赞赏...
谢谢,
马特