dub*_*eat 2 iphone uinavigationcontroller
我只是想知道它是否可以在UINavigationControllers标题栏中添加UIButton或图标?
我问,因为我正在寻找一个一致的位置来显示一个"关于"按钮.
您可以通过视图控制器的viewDidLoad方法执行此操作:
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem* infoButton = [[UIBarButtonItem alloc] initWithTitle:@"Info"
style:UIBarButtonItemStylePlain
target:self
action:@selector(infoButtonSelected:)];
self.navigationItem.rightBarButtonItem = infoButton;
[infoButton release];
}
Run Code Online (Sandbox Code Playgroud)
在关于按下按钮的示例中,您还应该具有以下方法:
- (void)infoButtonSelected:(id)sender {
NSLog(@"button tapped");
// whatever needs to happen when button is tapped
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2716 次 |
| 最近记录: |