如何在导航栏的左侧同时显示后退按钮和另一个按钮?因为这是一个ipad应用程序,所以有多个按钮的空间。但我只能在导航仪上每侧显示一个按钮...
答案 0 :(得分:2)
对于那些偶然发现并对链接断开感到失望的人,请查看以下文章:
http://osmorphis.blogspot.com/2009/05/multiple-buttons-on-navigation-bar.html
答案 1 :(得分:2)
iOS现在支持同一侧的多个按钮。来自 UINavigationItem 文档:
自定义视图
titleView property
leftBarButtonItems property
leftBarButtonItem property
rightBarButtonItems property
rightBarButtonItem property
– setLeftBarButtonItems:animated:
– setLeftBarButtonItem:animated:
– setRightBarButtonItems:animated:
– setRightBarButtonItem:animated:
所以,基本上,你会写这样的东西在左边添加两个按钮:
UIBarButtonItem *refreshBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshPlans:)];
UIBarButtonItem *selectYearBtn = [[UIBarButtonItem alloc] initWithTitle:@"Select Year" style:UIBarButtonSystemItemAction target:self action:@selector(selectYear)];
self.navigationItem.leftBarButtonItems = [[NSArray alloc] initWithObjects: refreshBtn, selectYearBtn, nil];
不幸的是,我还没有在Storyboard中看到过这样做的方法。希望这会有所帮助。
答案 2 :(得分:0)
UIBarButtonItem *btn0 = [[UIBarButtonItem alloc] initWithTitle:@"1" style:UIBarButtonItemStylePlain target:self action:@selector(tapLevel0)];
UIBarButtonItem *btn1 =[[UIBarButtonItem alloc] initWithTitle:@"<2" style:UIBarButtonItemStylePlain target:self action:@selector(tapLevel1:)];
UIBarButtonItem *btn2 = [[UIBarButtonItem alloc] initWithTitle:@"<3" style:UIBarButtonItemStylePlain target:self action:@selector(tapLevel2:)];
UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
space.width = 10;
UIBarButtonItem *space2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
space2.width = 10;
// UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshItem)];
self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:btn0, space, btn1, space2, btn2, nil];
答案 3 :(得分:-1)