当名称来自用户添加时,我在推送 ABpersonViewController 时遇到问题,然后一切正常,但是当名称来自默认模拟器条目时,它不起作用我将在代码中详细解释
-(void)showPersonViewController:(NSString *)name
{
ABAddressBookRef addressBook = ABAddressBookCreate();
NSString *string = name;
NSLog(@"%@",string);
CFStringRef cfstringRef = (CFStringRef)string;
NSArray *peoplee = (NSArray *)ABAddressBookCopyPeopleWithName(addressBook, cfstringRef);
NSLog(@"%@",peoplee);
// 1ST QUESTION when contact is from defalut contact nslog is null but when from user added then it has value I dont understand why this is happening
if ((peoplee != nil) && [peoplee count])
{
ABRecordRef person = (ABRecordRef)[peoplee objectAtIndex:0];
ABPersonViewController *picker = [[ABPersonViewController alloc] init];
picker.personViewDelegate = self;
picker.displayedPerson = person;
picker.allowsEditing = YES;
[self.navigationController pushViewController:picker animated:YES];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Could not find Appleseed in the Contacts application"
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil];
[alert show];
}
CFRelease(addressBook);
}