1

I've encountered a strange problem in my IOS 8 people picker delegate code. Only the

- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController    *)peoplePicker;
{
    [self dismissViewControllerAnimated:YES completion:NULL];
}

method is being called. I have reviewed other questions and have made the important IOS 8 delegate method changes for selecting a contact by calling the old IOS 7 method

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:   (ABMultiValueIdentifier)identifier {
    [self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person property:property identifier:identifier];
}

but it is never called.

I am setting the delegate in the calling viewcontroller didLoad,

and it works perfectly in ios 7. This is a storyboard application.

I saw the same question asked in a comment here: ABPeoplePickerNavigationController changes with iOS8?

but never found an answer. Obviously a mistake somewhere on my part, but I can't find it.

UPDATE: As requested, here is how I set the delegate:

self.picker = [[ABPeoplePickerNavigationController alloc] init];
self.picker.peoplePickerDelegate = self;

And, in @interface:

@interface TreatmentsAddEntryTVC :    UITableViewController<UITextViewDelegate,ABPeoplePickerNavigationControllerDelegate>
Community
  • 1
  • 1
jmf1205
  • 437
  • 6
  • 23

3 Answers3

0

Try using this delegate method instead and see if it hits:

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person;
{
   // yes the below line is deprecated as of iOS 8
   [self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person];
}
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • Did you add "``" to your "`@interface`" declaration in your view controller's .h file? Also, you should edit your question to show how you set the delegate in your view controller. – Michael Dautermann Nov 02 '14 at 06:30
  • change your declaration to: "`@interface TreatmentsAddEntryTVC : UITableViewController `" and see what happens. – Michael Dautermann Nov 02 '14 at 06:41
  • @MichaelDautermann - Doesn't work, idk whats wrongs when one delegate is being called and others are not ! –  Jul 22 '16 at 06:24
0

I hate to answer my own question, especially when the answer makes no sense, but moving:

self.picker = [[ABPeoplePickerNavigationController alloc] init];
self.picker.peoplePickerDelegate = self;

from didLoad to the method where I actually want to display the picker fixed the problem. I have seen at least one other question on SO where this behavior was noted and discussed:

Cannot select contact on iOS 8

Community
  • 1
  • 1
jmf1205
  • 437
  • 6
  • 23
  • I am facing the same issue and i tried what you mentioned here, did you find any other solution ? Please share if you did. –  Jul 22 '16 at 06:25
  • Sorry for the delay in answering - that's all I can tell you. If you are still stuck I will be happy to dig through my older code for anything that might be helpful. – jmf1205 Aug 25 '16 at 15:11
0

For a project with iOS 8.1, I replaced this method

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

with this

-(void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person{
}

And new method did hit when I selected a contact.

kalan nawarathne
  • 1,944
  • 27
  • 26