【发布时间】:2012-09-06 14:41:34
【问题描述】:
如何在导航栏上再添加两个按钮?。我的代码如下。如果我使用 rightBarButtonItem 方法,则项目没有问题。
UIBarButtonItem *barPrint = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"tool_print.png"]
style:UIBarButtonItemStylePlain
target:self
action:@selector(printAttach:)];
UISwitch *OnOff = [[UISwitch alloc] init];
UIBarButtonItem *barOnOff = [[UIBarButtonItem alloc] initWithCustomView:OnOff];
//[onoff1 addTarget: self action: @selector(flip:) forControlEvents:UIControlEventValueChanged];
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:barOnOff, barPrint, nil];
[OnOff release];
【问题讨论】:
-
试试
self.navigationController.navigationBar.items = [NSArray arrayWithObjects:...]; -
代码没问题,但问题不清楚...你在酒吧里有 2 件物品吗?
-
运行时出现错误..如果我只显示一项就可以了,我的代码有什么问题吗?..我对我的 barPrint 按钮有疑问。
-
我做到了。为此,我使用了以下链接。 stackoverflow.com/questions/6249416/…谢谢你的评论
标签: iphone ipad uinavigationbar