如何启动只有手机号码的联系人的ABPeoplePickerNavigationController?

时间:2015-04-24 05:56:48

标签: ios cocoa-touch abaddressbook

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"];

如何仅显示包含手机/电话号码的联系人?我已经挖掘了Apple文档以找到用于@count操作的密钥(在此示例中为emailAddresses),但我找不到它。

1 个答案:

答案 0 :(得分:2)

像这样使用ABPersonPhoneNumbersProperty

[NSPredicate predicateWithFormat:@"%K.@count > 0", ABPersonPhoneNumbersProperty];