【发布时间】:2011-08-01 02:33:26
【问题描述】:
如何在 UINavigation 栏上添加大约 5 个按钮。
我很好,我们可以为导航添加左右按钮
使用 UIToolbar 我们在导航栏上添加按钮。
是任何其他适合导航栏周围五个按钮的方式。接受苹果的地方
【问题讨论】:
标签: iphone objective-c
如何在 UINavigation 栏上添加大约 5 个按钮。
我很好,我们可以为导航添加左右按钮
使用 UIToolbar 我们在导航栏上添加按钮。
是任何其他适合导航栏周围五个按钮的方式。接受苹果的地方
【问题讨论】:
标签: iphone objective-c
您始终可以使用[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];
【讨论】: