2010-04-27 23 views
3

使用peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person時,將顯示包含所有聯繫人信息的視圖。我見過只顯示選定信息的應用程序(例如電話號碼)。如何使用ABPeoplePicker隱藏一些屬性

我該怎麼做?我只想顯示聯繫人的姓名和電話號碼。

非常感謝!

回答

8

這很簡單。我自定義ABPeoplePickerNavigationController以僅顯示電子郵件地址。

的代碼看起來是這樣的:

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

您可以找到可用的屬性here的列表。

0

我不知道,如果你能,

你能做到這一點,以獲得地址簿的人員名單:

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

CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook); 

,然後創建自己的自定義選擇器視圖,只顯示你想要的信息。

0

在Swift中,您只需執行此操作。

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