![](/img/trans.png)
[英]How to add NavigationBar and button in UIPickerView of iPhone Programming?
[英]How to add 5 button on NavigationBar
如何在UINavigation栏上添加大约5个按钮。
我很好,我们可以向左右添加按钮进行导航
使用UIToolbar,我们在导航栏上添加按钮。
还有其他适合导航栏周围五个按钮的方式。 苹果被接受的地方
您可以始终使用[self.navigationController.navigationBar addSubview: abutton];
。
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:5];
// create a standard "1" button
UIBarButtonItem* bi = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:NULL];
bi.style = UIBarButtonItemStyleBordered;
[buttons addObject:bi];
[bi release];
//for spacer
bi = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
[buttons addObject:bi];
[bi release];
// create a standard "2" button
bi = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh:)];
bi.style = UIBarButtonItemStyleBordered;
[buttons addObject:bi];
[bi release];
// and so on you can create rest button in the same way and add to tools
// stick the buttons in the toolbar
[tools setItems:buttons animated:NO];
[buttons release];
// and put the toolbar in the nav bar
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools];
[tools release];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.