带有多个按钮的导航栏 [英] Navigation bar with multiple buttons
本文介绍了带有多个按钮的导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带左右按钮的导航栏,我需要在右键旁边放另一个按钮。有谁知道我怎么能这样做?这里有一些代码可以帮助:
I have a navigation bar with a left and right button, and I need to put another button next to the right button. Does anyone know how I can go about this? Here is some code to help:
- (id)init {
self = [super initWithStyle:UITableViewStyleGrouped];
if (self) {
_pinArray = [[NSArray alloc]init];
_pinArray = [Data singleton].annotations;
UIBarButtonItem *right = [[UIBarButtonItem alloc]initWithTitle:@"Map"
style:UIBarButtonItemStylePlain
target:self
action:@selector(goToMap:)];
self.navigationItem.rightBarButtonItem = right;
UIBarButtonItem *left = [[UIBarButtonItem alloc]initWithTitle:@"Menu"
style:UIBarButtonItemStylePlain
target:self
action:@selector(goToMenu:)];
self.navigationItem.leftBarButtonItem = left;
self.navigationItem.title = @"My Homes";
}
return self;
}
推荐答案
这很容易:)
https:// developer.apple.com/documentation/uikit/uinavigationitem/1624956-rightbarbuttonitems
navigationItem.rightBarButtonItems = [rightA, rightB] // @[rightA, rightB] for ObjC
这篇关于带有多个按钮的导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文