-1
Stackoverflow上的其他人發佈了一種從聯繫人列表中獲取用戶所選電話號碼的方法。可以做電子郵件地址,如果是的話,我該怎麼做?下面是代碼:如何從ABPeoplePicker獲取用戶選擇的電子郵件地址?
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
if (property == kABPersonPhoneProperty) {
ABMultiValueRef multiPhones = ABRecordCopyValue(person, kABPersonPhoneProperty);
for(CFIndex i = 0; i < ABMultiValueGetCount(multiPhones); i++) {
if(identifier == ABMultiValueGetIdentifierAtIndex (multiPhones, i)) {
CFStringRef phoneNumberRef = ABMultiValueCopyValueAtIndex(multiPhones, i);
CFRelease(multiPhones);
NSString *phoneNumber = (__bridge NSString *) phoneNumberRef;
CFRelease(phoneNumberRef);
_contactNumber.text = [NSString stringWithFormat:@"%@", phoneNumber];
}
}
}
[self dismissViewControllerAnimated:YES completion:nil];
return NO;
}
這裏是鏈接到後: How do you get a persons phone number from the address book?
非常感謝你實現吧!這幫了我很多! –