iosios8addressbookui

Cannot select contact on iOS 8


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];
}

Solution

  • Where are you specifying the peoplePickerDelegate?

    In iOS 8, if you specify peoplePickerDelegate in viewDidLoad, you will experience the curious behavior you describe (cancel delegate works, the didSelect... and shouldContinue... do not). If you specify peoplePickerDelegate immediately after init (or during), it works fine.

    This would appear to be an iOS 8 "feature". I'll file a bug report.