我想通過添加自定義UIBarButtonItem
作爲UINavigationController
的頂視圖控制器的左右barbuttonitem來自定義ABPeoplePickerNavigationController
的導航欄。此功能在iOS7和以前的版本工作正常,但不是在iOS的8在iOS 8中自定義ABPeoplePickerNavigationController的導航欄
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
navigationController.topViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addNewContact:)];
navigationController.topViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel:)];
}
正在執行上面的代碼,但它沒有任何效果。 PeoplePickerNavigationController顯示其默認導航欄及其默認項目Groups和Cancel按鈕。
iOS 8中發生了什麼變化?我是否需要重新實施,我已經做了什麼?
編輯: 我在導航堆棧中記錄了頂部ViewController。它被稱爲CNContactPicker
。
您是否嘗試過設置? navigationController.topViewController.navigationItem.rightBarButtonItems navigationController.topViewController.navigationItem.leftBarButtonItems 代替rightBarButtonItem和leftBarButtonItem – 2014-09-26 05:51:44
是的,試過了。但它不起作用。 – 2014-09-26 06:20:07
@XaviValero,我遇到了和你一樣的問題。你有沒有找到解決方案?我會很感激,如果你能幫助我 – 2015-08-31 08:07:40