我正在尝试自定义ABPeoplePickerNavigationController的导航栏,通过添加自定义UIBarButtonItem作为UINavigationController的顶视图控制器的左右barbuttonitem.此功能在iOS7和以前的版本中正常工作,但不在iOS 8中运行.
- (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显示其默认导航栏,其默认项为“组”和“取消”按钮.
iOS 8有什么变化?我需要重新实施,我已经做了什么?
编辑:
我在导航堆栈中登录了顶部的ViewController.它被称为CNContactPicker.