【发布时间】:2014-09-24 05:28:01
【问题描述】:
我正在尝试自定义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 显示其默认导航栏,以及其默认项 Groups 和 Cancel 按钮。
iOS 8 发生了什么变化?我需要重新实现,我已经做了什么?
编辑:
我在导航堆栈中记录了顶部的 ViewController。它被称为CNContactPicker。
【问题讨论】:
-
你试过设置这个吗? navigationController.topViewController.navigationItem.rightBarButtonItems navigationController.topViewController.navigationItem.leftBarButtonItems 而不是 rightBarButtonItem 和 leftBarButtonItem
-
是的,也试过了。但它不起作用。
-
@XaviValero,我遇到了和你一样的问题。你找到解决方案了吗?如果您能帮助我,我将不胜感激
-
@pf2707 没有伙伴。我不得不放弃计划并改变设计。如果您发现有帮助,请在此处发布答案。谢谢。
-
@XaviValero,感谢您的确认,非常感谢
标签: ios iphone uinavigationcontroller ios8 abpeoplepickerview