ABPeoplePickerNavigationController changes with iOS8?

后端 未结 3 1456
一生所求
一生所求 2020-12-02 22:16

Since I have updated XCode (6.0, 6A313) and my iOS (8.0, 12A365) on the iPhone to gm seeds, the ABPeoplePickerNavigationController code doesn\'t work like before.

相关标签:
3条回答
  • 2020-12-02 22:51

    iOS 8 requires a new delegate method be implemented for this:

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

    Keep the old delegate method in place to support iOS 7 or earlier. What I do in my app is call the iOS 7 delegate method from the iOS 8 delegate method:

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

    If this delegate method isn't implemented in iOS 8, tapping the value causes the action. When implemented, the delegate is called instead with the selected value.

    0 讨论(0)
  • 2020-12-02 23:06

    This worked for me on both iOS 8 and iOS 7 and lower.

    Note I am using this didSelectPerson:(ABRecordRef)person instead.

    //Needed for iOS 8
    - (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person
    {
        NSLog(@"Went here 1 ...");
    
        [self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person];
    }
    
    
    //needed for iOS 7 and lower
    - (BOOL)peoplePickerNavigationController:
    (ABPeoplePickerNavigationController *)peoplePicker
          shouldContinueAfterSelectingPerson:(ABRecordRef)person 
    {
    
        NSLog(@"Went here 2 ...");
    
        //add your logic here
    
    }
    
    0 讨论(0)
  • 2020-12-02 23:10

    See also the delegate method, new with iOS8:

    - (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person;
    {
        [self selectedPerson:person];
    }
    

    That's what I wanted in my case.

    0 讨论(0)
提交回复
热议问题