我正在尝试在下面提到的委托回调中获取选定的电子邮件属性
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
if (property==kABPersonEmailProperty) {
ABMultiValueRef emails = ABRecordCopyValue(person, kABPersonEmailProperty);
if (ABMultiValueGetCount(emails) > 0) {
NSString *email = (__bridge_transfer NSString*)
ABMultiValueCopyValueAtIndex(emails, ABMultiValueGetIndexForIdentifier(emails,identifier));
[recipientEmail setText:email];
[peoplePicker dismissViewControllerAnimated:YES completion:nil];
}
CFRelease(emails);
}
return NO;
}
但是,如果我选择链接联系人的电子邮件属性(有单个电子邮件),我会得到标识符为 0,因此我会得到主要联系人的第一个电子邮件 ID。例如:John - john@gmail.com john26@gmail.com Roger(关联联系人) - roger@gmail.com
当我选择 roger@gmail.com 时,我得到 john@gmail.com。