2013-08-23 43 views
1

XCode中MasterDetail模板的默認添加按鈕顯示+符號。我寧願使用「添加」一詞。我嘗試在viewDidLoad方法中使用以下行:如何更改添加按鈕文本而不是

self.navigationItem.rightBarButtonItem.title = @「Add」;

無濟於事。

回答

2

這可能是因爲已經被創建爲UIBarButtonSystemItemAdd像這樣的欄按鈕:

UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)]; 

您應該重寫此行以創建欄按鈕項目有一個標題,就像這樣:

UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:@"Add" style:UIBarButtonItemStyleBordered target:self action:@selector(insertNewObject:)]; 

您可以在主視圖控制器的viewDidLoad方法中找到它。

相關問題