I have a subclass of ABPeoplePickerNavigationController
to handle selecting a contact phone number in my app. Everything works great on iOS 7 and below.
On iOS 8, however, my ABPeoplePickerNavigationControllerDelegate
does not get hit when selecting a phone number. Instead, it just calls that phone number.
I noticed that the method I was using to handle contact selection in iOS 7 (peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier:
) was deprecated in iOS 8. This method was replaced by peoplePickerNavigationController:didSelectPerson:property:identifier:
.
I know my delegate is set because I successfully receive the peoplePickerNavigationControllerDidCancel:
method callback.
Has anyone else experienced this issue?
Here's a code snippet of my ABPeoplePickerNavigationController
subclass:
- (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];
}
Where are you specifying the
peoplePickerDelegate
?In iOS 8, if you specify
peoplePickerDelegate
inviewDidLoad
, you will experience the curious behavior you describe (cancel delegate works, thedidSelect...
andshouldContinue...
do not). If you specifypeoplePickerDelegate
immediately afterinit
(or during), it works fine.This would appear to be an iOS 8 "feature". I'll file a bug report.
Nothing would happen when I selected a contact in IOS8.
I found that in addition to
I also needed
Source https://developer.apple.com/library/prerelease/ios/samplecode/PeoplePicker/Listings/PeoplePicker_AAPL_8or7_EmailPickerViewController_m.html
above two delegate methods are deprecated in iOS 8.0, use last two methods for getting your desire result
this is apple developer guideline link give you more information about
ABPeoplePickerNavigationControllerDelegate
If you wanna just get person's name you can do this :
But if you are looking to go to person's detail to get person's numbers, you should use
BOOL
insteadvoid
forpeoplePickerNavigationController
and passYES
like below :Also dont forget to import
AddressBook.framework
andAddressBookUI.framework
to your project andABPeoplePickerNavigationControllerDelegate
,to your header file.