简体   繁体   中英

How do I handle selecting a property in ABPeoplePickerNavigationController?

I am having some trouble with this.. I see that we are supposed to be using the property:

predicateForSelectionOfProperty

for determining which properties get 'selected', and I'm actually kind of bummed for there not being a

predicateForEnablingProperty

because I only want phone numbers, for my use case.

That said, nothing I use for predicateForSelectionOfProperty seems to do what I want. What I want is, when I select a contact's phone number, it should call the delegate callback.. but instead, right now, it is calling them!

Maybe I'm just completely missing something, because I would actually rather just have a list of my contacts, with phone numbers, and only show the phone numbers.. maybe I'm not even heading in the right direction with this.

Thanks for any help you can offer!

  1. If you don't want it to call the number, you should:

    • specify the peoplePickerDelegate ; and

    • implement peoplePickerNavigationController:didSelectPerson:property:identifier:

    • don't specify a predicateForSelectionOfProperty (or if you do, make sure it returns true , eg NSPredicate(value: true) )

  2. Obviously, if you don't even want it to show you unrelated information about contacts, specify the displayedProperties array, eg

     controller.displayedProperties = [NSNumber(int: kABPersonPhoneProperty)] 
  3. Alternatively, if you wanted to customize this UI further, you could just use the AddressBook.framework to extract the phone numbers from the address book and present whatever UI you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM