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
),但我找不到它。
答案 0 :(得分:2)
像这样使用ABPersonPhoneNumbersProperty
:
[NSPredicate predicateWithFormat:@"%K.@count > 0", ABPersonPhoneNumbersProperty];