如何使用 ABPeoplePicker 隐藏某些属性

发布于 2024-08-31 02:53:35 字数 250 浏览 6 评论 0原文

使用 peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person 时,会显示包含所有联系人信息的视图。我见过仅显示选定信息(例如电话号码)的应用程序。

我该怎么做?我只想显示联系人的姓名和电话号码。

非常感谢!

When using peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person, a view with all of the contact's information is shown. I've seen apps which only display selected info only (e.g. phone numbers).

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

Thank you very much!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

錯遇了你 2024-09-07 02:53:35

这很简单。我将 ABPeoplePickerNavigationController 自定义为仅显示电子邮件地址。

代码如下所示:

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

您可以找到可用属性的列表 此处

It's pretty simple. I customized ABPeoplePickerNavigationController to only show email addresses.

The code looks like this:

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

You can find a list of the available properties here.

似梦非梦 2024-09-07 02:53:35

我不确定您是否可以,

您可以这样做来获取地址簿的人员列表:

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

CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);

然后创建您自己的自定义选择器视图,仅显示您想要的信息。

I'm not sure if you can,

You could do this to get a list of people for the address book:

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

CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);

and then create your own custom picker view, showing only the information you want.

绿萝 2024-09-07 02:53:35

在 Swift 中,您只需执行此操作即可。

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

In Swift, you simply do this.

var people = ABPeoplePickerNavigationController()
people.peoplePickerDelegate = self
// 3 is for Phone Number
people.displayedProperties = [3]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文