2013-02-10 41 views
0

我有以下代码:的UIBarButtonItem与自定义标题

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

我想创建一个自定义标题的UIBarButtonItem。为什么上述说取消而不是促进?

关于如何解决这个问题的任何想法?

回答

1

使用正确的初始值设定项,也许?

- (id)initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action 
0
UIBarButtonItem btnSort = [[UIBarButtonItem alloc]initWithTitle:@"Descending" style:UIBarButtonItemStyleBordered target:self action:@selector(pressAscending)]; 
    [[self navigationItem] setRightBarButtonItem:btnSort];