我有一个 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/