use*_*878 3 iphone uinavigationbar
我是iPhone开发的新手.
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:@"SAVE"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(saveButtonClicked)];
self.navigationItem.rightBarButtonItem = saveButton;
Run Code Online (Sandbox Code Playgroud)
通过使用上面,我可以创建导航右栏按钮,但我不能添加更多项目...我需要添加更多按钮
请提供一个示例代码来试用它
感谢您的帮助和感谢您的时间
将工具栏添加到导航栏
UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 133, 44.01)];
tools.tintColor = [UIColor blackColor];
// create the array to hold the buttons, which then gets added to the toolbar
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:2];
// create a standard "add" button
bi = [[UIBarButtonItem alloc]
initWithTitle:@"Add" style:UIBarButtonItemStyleBordered target:self action:@selector(addMedicine)];
[buttons addObject:bi];
[bi release];
// create a spacer
bi = [[UIBarButtonItem alloc]
initWithTitle:@"Edit" style:UIBarButtonSystemItemEdit target:self action:@selector(edit)];
[buttons addObject:bi];
[bi release];
// 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];
Run Code Online (Sandbox Code Playgroud)
祝一切顺利.
| 归档时间: |
|
| 查看次数: |
2182 次 |
| 最近记录: |