作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
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; 中崩溃作为[Not A Type retain]: 发送到释放实例的消息
最佳答案
尝试不从 Controller 获取 addressBook,而是显式地创建它:
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, &err);
ABRecordRef person = ABAddressBookGetPersonWithRecordID(addressBook, [recordID intValue]);
关于iOS8 在重定向到 ABPersonViewController 时崩溃 [Not A Type retain] : message sent to deallocated instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26053390/
我是一名优秀的程序员,十分优秀!