How to hide some properties using ABPeoplePicker

When using the peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)persondisplayed view with all the contact information. I saw applications that display only selected information (e.g. phone numbers).

How can i do this? I want to display only the contact name and phone numbers.

Many thanks!

+3
source share
3 answers

It is pretty simple. I configured ABPeoplePickerNavigationController only to display email addresses.

The code is as follows:

ABPeoplePickerNavigationController *peoplePicker = [[ABPeoplePickerNavigationController alloc] init];
    [peoplePicker setPeoplePickerDelegate:self];
    [peoplePicker setDisplayedProperties:[NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonEmailProperty]]];

You can find a list of available properties here .

+8
source

, ,

, :

// get the default address book. 
ABAddressBookRef addressBook = ABAddressBookCreate();

CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);

, .

0

In Swift, you just do it.

var people = ABPeoplePickerNavigationController()
people.peoplePickerDelegate = self
// 3 is for Phone Number
people.displayedProperties = [3]
0
source

Source: https://habr.com/ru/post/1742940/


All Articles