ios - 无法在 iOS 8 上选择联系人

标签 ios ios8 addressbookui

我有一个 ABPeoplePickerNavigationController 的子类来处理在我的应用程序中选择联系电话号码。在 iOS 7 及更低版本上一切正常。

但是,在 iOS 8 上,我的 ABPeoplePickerNavigationControllerDelegate 在选择电话号码时不会被点击。相反,它只是调用那个电话号码。

我注意到我在 iOS 7 中用来处理联系人选择的方法 (peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier:) 在 iOS 8 中被弃用了。这个方法被替换为 peoplePickerNavigationController :didSelectPerson:property:identifier:.

我知道我的委托(delegate)已设置,因为我成功收到了 peoplePickerNavigationControllerDidCancel: 方法回调。

有没有其他人遇到过这个问题?

这是我的 ABPeoplePickerNavigationController 子类的代码片段:

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {

    [self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person property:property identifier:identifier];
}

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {

    ...do stuff...

    return NO;
}

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {

    return YES;
}

- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker {

    [self dismissViewControllerAnimated:self.shouldAnimateDismiss completion:NULL];
}

最佳答案

您在哪里指定 peoplePickerDelegate

在 iOS 8 中,如果您在 viewDidLoad 中指定 peoplePickerDelegate,您将遇到您描述的奇怪行为(取消委托(delegate)有效,didSelect...shouldContinue... 不)。如果您在 init 之后(或期间)立即指定 peoplePickerDelegate,它会正常工作。

这似乎是 iOS 8 的“功能”。我将提交错误报告。

关于ios - 无法在 iOS 8 上选择联系人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26024611/

相关文章:

ios8 - Xcode 6.3 和 Crashlytics/其他崩溃报告工具

iphone - 如何将字符串对象传递给 ABNewPersonViewController.h 的名称字段?

ios - 请求有关用户 iOS 的数据

ios - 同时在多个 UICollectionView 上调用 reloadData

iphone - 带箭头的透明屏幕

swift - 为什么在 Swift 中只使用类协议(protocol)?

iOS8 - 没有方法直接出现推送通知权限弹窗

ios - 自定义部分标题 View 时部分标题标题丢失

iphone - UIViewController 或 UINavigationController 是否设置其 View 的大小?

swift - swift 从 AddressBook 框架返回空值