如何仅启动具有手机号码的联系人的 ABPeoplePickerNavigationController?
How to launch an ABPeoplePickerNavigationController of only contacts that have mobile numbers?
Apple 提供了一个名为 PeoplePicker 的示例项目,它启动了一个 ABPeoplePickerNavigationController
只有拥有电子邮件地址的联系人:
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
// The people picker will only display the person's name, image and email properties in ABPersonViewController.
picker.displayedProperties = @[@(kABPersonEmailProperty)];
// The people picker will enable selection of persons that have at least one email address.
picker.predicateForEnablingPerson = [NSPredicate predicateWithFormat:@"emailAddresses.@count > 0"];
如何只显示有 mobile/telephone 个号码的联系人?我已经在 Apple 文档中查找要用于 @count
操作的密钥(本例中为 emailAddresses
),但我找不到它。
像这样使用ABPersonPhoneNumbersProperty
:
[NSPredicate predicateWithFormat:@"%K.@count > 0", ABPersonPhoneNumbersProperty];
Apple 提供了一个名为 PeoplePicker 的示例项目,它启动了一个 ABPeoplePickerNavigationController
只有拥有电子邮件地址的联系人:
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
// The people picker will only display the person's name, image and email properties in ABPersonViewController.
picker.displayedProperties = @[@(kABPersonEmailProperty)];
// The people picker will enable selection of persons that have at least one email address.
picker.predicateForEnablingPerson = [NSPredicate predicateWithFormat:@"emailAddresses.@count > 0"];
如何只显示有 mobile/telephone 个号码的联系人?我已经在 Apple 文档中查找要用于 @count
操作的密钥(本例中为 emailAddresses
),但我找不到它。
像这样使用ABPersonPhoneNumbersProperty
:
[NSPredicate predicateWithFormat:@"%K.@count > 0", ABPersonPhoneNumbersProperty];