如何使用 cncontact picker delegate 在一个联系人中选择多个号码?我正在使用以下方法,但我无法选择数字 - (void)contactPicker:(CNContactPickerViewController *)picker didSelectContactProperty:(CNContactProperty *)contactProperty;
问问题
294 次
1 回答
0
我很久以前就解决了我的问题,最近发布这是我的答案,它可能对其他人有帮助,这就是我在这里发布的原因。
#pragma mark - CNContactPickerViewController Delegate method implementation
(void)contactPicker:(CNContactPickerViewController *)picker didSelectContact:(CNContact *)contact
{
NSMutableArray *contactNumberArray = [[NSMutableArray alloc]init];
selectedName=[NSString stringWithFormat:@"%@",contact.givenName];
NSLog(@"%@",selectedName);
NSString *tempString = [NSString stringWithFormat:@"name : %@ %@ %@\n",contact.givenName, contact.familyName, contact.organizationName];
// // 1. (Phone Numbers)
tempString = [NSString stringWithFormat:@"%@phoneNumbers : ",tempString];
// NSArray*phoneNumber = contact.phoneNumbers;
for (CNLabeledValue *phoneNumber in contact.phoneNumbers)
{
CNPhoneNumber *phone = phoneNumber.value;
tempString = [NSString stringWithFormat:@"%@<%@>",tempString,phone.stringValue];
[contactNumberArray addObject:phone];
selectedPhNumber=[[NSString stringWithFormat:@"%@",phone.stringValue] stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"%@",selectedPhNumber);
}
//2. (Emails)
tempString = [NSString stringWithFormat:@"%@\n Email : ",tempString];
for (CNLabeledValue *email in contact.emailAddresses)
{
selectedEmail=[NSString stringWithFormat:@"%@", email.value];
tempString = [NSString stringWithFormat:@"%@<%@>",tempString,email.value];
[contactNumberArray addObject:email];
NSLog(@"%@",selectedEmail);
}
[self sendRefferelDetailsToServer];
}
于 2017-12-29T11:04:56.797 回答