0

可能重复:
在导航栏上添加两个以上的按钮

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

1 回答 1

0
 UIView *iv = [[UIView alloc] initWithFrame:CGRectMake(0,0,32,32)];
 [iv setBackgroundColor:[UIColor whiteColor]];
  self.navigationItem.titleView = iv;
于 2012-09-06T15:26:56.350 回答