【发布时间】:2014-09-24 11:34:23
【问题描述】:
一年前我一直在使用 ios7 开发一个 iOS 应用程序,现在我将它升级到 ios8 ,发现有一种新的方式来挑选联系人。
我现在要做的是:
-(void)showABNewPersonViewController{
//Calling the addresbook
ABPeoplePickerNavigationController *picker =
[[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self presentViewController:picker animated:YES completion:nil];
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person{
//Getting contact email and phone number then assign it to there tb's.
ABMultiValueRef emails = (ABMultiValueRef) ABRecordCopyValue(person, kABPersonEmailProperty);
CFStringRef emailID = ABMultiValueCopyValueAtIndex(emails, 0);
_tbContactPersonEmail.text = [NSString stringWithFormat:@"%@", emailID];
CFRelease(emailID);
CFRelease(emails);
ABMultiValueRef phone = (ABMultiValueRef) ABRecordCopyValue(person, kABPersonPhoneProperty);
CFStringRef phoneID = ABMultiValueCopyValueAtIndex(phone, 0);
_tbContactPersonPhone.text = [NSString stringWithFormat:@"%@", phoneID];
CFRelease(phoneID);
CFRelease(phone);
[self fieldValueChanged:nil];
[self dismissViewControllerAnimated:YES completion:nil];
return NO;
}
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
return NO;
}
-(void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker{
[self dismissViewControllerAnimated:YES completion:nil];
}
使用该代码,我可以打开地址簿并选择一个联系人,但现在它不会返回他/她的姓名和号码,而是打开所选联系人的一种详细视图。
我的 peoplePickerNavigationController 没有被调用
感谢您的帮助和快速回答¨
【问题讨论】:
标签: ios objective-c