代码之家  ›  专栏  ›  技术社区  ›  rein

以编程方式更改UIBarButtonItem的标识符属性

  •  5
  • rein  · 技术社区  · 16 年前

    我该如何通过编程方式进行设置?UIBarButtonItem不接受“setIdentifier”消息。

    3 回复  |  直到 13 年前
        1
  •  6
  •   Mark rein    11 年前

    UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd 
                                                                               target:self 
                                                                               action:@selector(doAddAction:)];
    
        2
  •  2
  •   Cristian Pereira    14 年前

    如果你想要一个按钮样式:带边框和标识符:相机使用

    UIBarButtonItem *btn;
    btn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(shotAction:)];
    btn.style=UIBarButtonItemStyleBordered;
    
        3
  •  0
  •   MobileMon    11 年前

    UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                                  target:self
                                                                  action:@selector(buttonClickedAction:)];
    
    self.navigationItem.rightBarButtonItem = barButton;