[英]Multiple Barbutton in Navigation Bar not showing on iOS6
I have added array of bar button to the navigation items using the property rightBarButtonItems,it work good for iOS5,when i tested in iOS6 only one bar button item is visible. 我使用属性rightBarButtonItems向导航项中添加了条形按钮数组,当我在iOS6中进行测试时,只有一个条形按钮项可见,它对iOS5效果很好。
UIBarButtonItem *updateButton = [[UIBarButtonItem alloc]
initWithTitle:@"Update"
style:UIBarButtonItemStylePlain
target:self
action:@selector(updateData)];
UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc]
initWithTitle:@"Refresh"
style:UIBarButtonItemStylePlain
target:self
action:@selector(refresh)];
NSArray *arrBtns = [[NSArray alloc]initWithObjects:updateButton,refreshButton, nil];
self.navigationItem.rightBarButtonItems=arrBtns;
Is there any new property for iOS6 to add the array of bar button to navigationitem. iOS6是否有任何新属性可将条形按钮数组添加到Navigationitem。
Any help would be appreciated,Thanks a lot. 任何帮助将不胜感激,非常感谢。
Please use the segmentController on the rightBarButtonItems if you want to add multiButton on rightBarButtonItems of NavigationBar 如果要在NavigationBar的rightBarButtonItems上添加multiButton,请在rightBarButtonItems上使用segmentController
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:
[NSArray arrayWithObjects:@"Add",@"Delete",
nil]];
segmentedControl.frame = CGRectMake(0, 0, 80, 30);
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
[segmentedControl setWidth:35.0 forSegmentAtIndex:0];
[segmentedControl setWidth:45.0 forSegmentAtIndex:1];
[segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
segmentedControl.momentary = YES;
UIBarButtonItem *segmentBarItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl];
[segmentedControl release];
self.navigationItem.leftBarButtonItem = segmentBarItem;
[segmentBarItem release];
Secondly add the second button on other side of the first bar Button. 其次,将第二个按钮添加到第一个按钮的另一侧。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.