【问题标题】:Add Two or more buttons on Navigationbar [duplicate]在导航栏上添加两个或更多按钮[重复]
【发布时间】:2012-09-06 14:41:34
【问题描述】:

可能重复:
adding more than two button on the navigationbar

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


【解决方案1】:
 UIView *iv = [[UIView alloc] initWithFrame:CGRectMake(0,0,32,32)];
 [iv setBackgroundColor:[UIColor whiteColor]];
  self.navigationItem.titleView = iv;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-09
    • 1970-01-01
    • 1970-01-01
    • 2012-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多