2013-02-10 89 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];