xcode 4.2开发 ——navigation controller 添加按钮
添加一個按鈕
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Add" style:UITabBarSystemItemContacts target:self action:@selector(clickSettings:)]; self.navigationItem.rightBarButtonItem = rightButton; ?
新版本xcode不用release
添加兩個按鈕
UIToolbar* toolBar= [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 150, 45)]; [toolBar setTintColor:[self.navigationController.navigationBar tintColor]];
[toolBar setAlpha:[self.navigationController.navigationBar alpha]];
NSMutableArray* buttonArray = [[NSMutableArray alloc] initWithCapacity:2];
?UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(clickSettings:)];
UIBarButtonItem *rightButton2 = [[UIBarButtonItem alloc] initWithTitle:@"Add" style:UITabBarSystemItemContacts target:self action:@selector(clickEdit:)];
? [buttonArray addObject:rightButton];
[buttonArray addObject:rightButton2];
?[toolBar setItems:buttonArray animated:NO];
UIBarButtonItem *barBI = [[UIBarButtonItem alloc] initWithCustomView:toolBar];
self.navigationItem.rightBarButtonItem = barBI;?
轉載于:https://www.cnblogs.com/5AnonymousAtBJTU/archive/2012/08/30/2664355.html
總結
以上是生活随笔為你收集整理的xcode 4.2开发 ——navigation controller 添加按钮的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Hamcrest断言
- 下一篇: 使用idea把Svn分支合并到主干上