【发布时间】:2014-09-18 00:51:10
【问题描述】:
我有人员选择器在 ios 7 上工作,我正在尝试添加对 ios 8 的兼容性。我已将这两种方法添加到一个中,但我收到一个错误,上面写着预期的标识符或 '(' 之前的左括号NSString *contactName。任何建议都会很棒!
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
[self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person property:property identifier:identifier];
NSString *contactName = CFBridgingRelease(ABRecordCopyCompositeName(person));
self.nameField.text = [NSString stringWithFormat:@"%@", contactName ? contactName : @"No Name"];
ABMultiValueRef phoneRecord = ABRecordCopyValue(person, kABPersonPhoneProperty);
CFStringRef phoneNumber = ABMultiValueCopyValueAtIndex(phoneRecord, 0);
self.phoneField.text = (__bridge_transfer NSString *)phoneNumber;
CFRelease(phoneRecord);
ABMultiValueRef email = ABRecordCopyValue(person, kABPersonEmailProperty);
CFStringRef emailField = ABMultiValueCopyValueAtIndex(email, 0);
self.emailField.text = (__bridge_transfer NSString *)emailField;
CFRelease(email);
CFDataRef photo = ABPersonCopyImageData(person);
UIImage* image = [UIImage imageWithData:(__bridge NSData*)photo];
if(photo)
CFRelease(photo);
if(image)
self.myImageView.image = image;
[self dismissViewControllerAnimated:YES completion:nil];
return NO;
}
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
[self dismissViewControllerAnimated:YES completion:nil];
return NO; }
【问题讨论】:
-
我要做的就是实现旧的委托方法和新的委托方法。将自动调用正确的。
-
谢谢!我认为这是一种更好的方法
-
我已经更新了我的代码 sn-p,它抛出了一个错误关于如何解决这个问题的任何想法?
-
在 peoplePickerNavigationController:didSelectPerson: 方法之后有一个不匹配的 "} {"
标签: ios objective-c ios7 ios8 abpeoplepickerview