如何在navaigationbar上再添加两个按钮?。我的代码如下。如果我使用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];
答案 0 :(得分:0)
UIView *iv = [[UIView alloc] initWithFrame:CGRectMake(0,0,32,32)];
[iv setBackgroundColor:[UIColor whiteColor]];
self.navigationItem.titleView = iv;