12

我正在尝试通过将自定义添加为顶部视图控制器的左右 barbuttonitem 来自ABPeoplePickerNavigationController定义导航栏。此功能在 iOS7 和以前的版本中运行良好,但在 iOS 8 中无法正常运行。UIBarButtonItemUINavigationController

- (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

4

1 回答 1

1

我来拍一张:

在 ios 8 中,我相信苹果已经以某种方式将其变成了扩展。这意味着代码是联系人应用程序的。它可能在另一个上下文中运行。

我认为这是因为我读到您不再需要向用户询问联系人列表访问权限以使用这些选择器。这一定意味着它们并不是您自己的应用程序的一部分,即扩展程序。

可能有一种方法可以防止这种情况。我敢打赌,您必须将 ABAddressBook 传递给选择器才能执行此操作。

于 2014-10-20T18:34:33.397 回答