苹果提供了一个名为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
),但是我找不到它。 最佳答案
像这样使用ABPersonPhoneNumbersProperty
:
[NSPredicate predicateWithFormat:@"%K.@count > 0", ABPersonPhoneNumbersProperty];