doc*_*606 2 iphone objective-c abpeoplepickerview ios
我开始为我的应用开发设置页面.
在此页面上,用户可以点击"+"按钮打开ABPeoplePickerNavigationController.点击联系人后,设置页面上的文本字段将使用所选用户的正确数据进行适当填充.
我明白,如果我想要检索某人的工作电子邮件,那就是:
NSString *workEmail = (__bridge NSString *)ABMultiValueCopyValueAtIndex(emails, 1);
Run Code Online (Sandbox Code Playgroud)
对于家庭来说,它将是:
NSString *homeEmail = (__bridge NSString *)ABMultiValueCopyValueAtIndex(emails, 0);
Run Code Online (Sandbox Code Playgroud)
但就检索不同类型的电话号码而言,我被困住了.
如果有人能告诉我如何获得与我收到两封电子邮件的方式类似的不同类型的电话号码,我将非常感激.
好吧,首先,您理解错误 - 无法保证用户的家庭电子邮件地址为#0.如果您只有该用户的工作电子邮件怎么办?然后该将在时隙0.
你想要的是ABMultiValueCopyLabelAtIndex(),当与命名常量一起使用时会告诉你哪个是:
ABPersonRef person = ...;
ABMultiValueRef phoneNumbers = ABRecordCopyValue(person, kABPersonPhoneProperty);
if (phoneNumbers) {
CFIndex numberOfPhoneNumbers = ABMultiValueGetCount(phoneNumbers);
for (CFIndex i = 0; i < numberOfPhoneNumbers; i++) {
CFStringRef label = ABMultiValueCopyLabelAtIndex(phoneNumbers, i);
if (label) {
if (CFEqual(label, kABWorkLabel)) {
/* it's the user's work phone */
} else if (CFEqual(label, kABHomeLabel)) {
/* it's the user's home phone */
} else if (...) {
/* other specific cases of your choosing... */
} else {
/* it's some other label, such as a custom label */
}
CFRelease(label);
}
}
CFRelease(phoneNumbers);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2222 次 |
| 最近记录: |