ABPersonViewController *personController = [[ABPersonViewController alloc] init];
personController.personViewDelegate = self;
ABRecordRef person = ABAddressBookGetPersonWithRecordID(personController.addressBook, [recordID intValue]);
personController.displayedPerson = person;
personController.allowsEditing = YES;
personController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back",nil) style:UIBarButtonItemStylePlain target:self action:@selector(returnFromPersonView)] ;
personController.navigationController.navigationBarHidden = NO;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:personController];
navController.navigationBar.tintColor=[UIColor colorWithRed:27/255.0 green:27/255.0 blue:29/255.0 alpha:1.0];
[self presentViewController:navController animated: YES completion:nil];
在此行发生崩溃personController.displayedPerson = person;如
[不保留类型]:发送到已释放实例的消息
最佳答案
尝试不从控制器获取addressBook,而是显式创建它:
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, &err);
ABRecordRef person = ABAddressBookGetPersonWithRecordID(addressBook, [recordID intValue]);