【问题标题】:UIBarButtonItem with custom title带有自定义标题的 UIBarButtonItem
【发布时间】:2013-02-10 18:20:46
【问题描述】:

我有以下代码:

 UIBarButtonItem *promoteButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonItemStyleBordered target:self action:@selector(promoteToInstagram:)];
    [promoteButton setTitle:@"Promote"];
    self.navigationItem.rightBarButtonItem = promoteButton;

我正在尝试创建一个带有自定义标题的 UIBarButtonItem。为什么上面说的是取消而不是推广?

知道如何解决这个问题吗?

【问题讨论】:

    标签: iphone ios objective-c ipad


    【解决方案1】:

    也许使用正确的初始化器?

    - (id)initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action
    

    【讨论】:

      【解决方案2】:
      UIBarButtonItem  btnSort = [[UIBarButtonItem alloc]initWithTitle:@"Descending" style:UIBarButtonItemStyleBordered target:self action:@selector(pressAscending)];
          [[self navigationItem] setRightBarButtonItem:btnSort];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-01-16
        • 1970-01-01
        • 1970-01-01
        • 2014-09-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-06
        相关资源
        最近更新 更多