可能重复:
在导航栏上添加两个以上的按钮
如何在导航栏上再添加两个按钮?. 我的代码如下。如果我使用 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];