我正在尝试获取选定的手机号码
ABMultiValueRef phones = ABRecordCopyValue(person, property);
CFStringRef phoneNumber = ABMultiValueCopyValueAtIndex(phones, identifier);
我与几部手机(都标有“移动”)有联系。当我选择第一个时, phoneNumber 给我第一个,但如果我选择任何连续的, phoneNumber 给我前一个号码:
接触:
杰伊·杰姆斯
手机 +1111111111
手机 +2222222222
手机 +3333333333
点击第一个,
phoneNumber
= +1111111111点击第二个,
phoneNumber
= +1111111111点击第三个,
phoneNumber
= +2222222222 最佳答案
这是我使用的代码。它只会给出正确的电话号码
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
if (property == kABPersonPhoneProperty) {
ABMultiValueRef phoneProperty = ABRecordCopyValue(person,property);
CFIndex peopleIndex = ABMultiValueGetIndexForIdentifier(property, identifier);
NSString *phone = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(phoneProperty, peopleIndex);
[self dismissModalViewControllerAnimated:YES];
}
return NO;
}
关于ios - peoplePickerNavigationController : shouldContinueAfterSelectingPerson: property: identifier:,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20141824/