带有自定义标题的UIBarButtonItem

时间:2013-02-10 10:17:09

标签: iphone ios objective-c ipad

我有以下代码:

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

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

有关如何解决这个问题的想法吗?

2 个答案:

答案 0 :(得分:1)

可能使用正确的初始化程序?

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

答案 1 :(得分:0)

UIBarButtonItem  btnSort = [[UIBarButtonItem alloc]initWithTitle:@"Descending" style:UIBarButtonItemStyleBordered target:self action:@selector(pressAscending)];
    [[self navigationItem] setRightBarButtonItem:btnSort];