我对联系人列表中的导入联系人有疑问。它是崩溃应用程序的原因。这是我的代码:
GKAddressBook *addressBook = [[GKAddressBook alloc] init];
ABAddressBookRequestAccessWithCompletion(addressBook.addressBookRef, ^(bool granted, CFErrorRef error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (granted) {
UINavigationController *nav = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactsPickerNavigationController"];
PDContactsPicker *picker = nav.viewControllers.firstObject;
picker.addressBook = addressBook;
picker.didSelectContactBlock = ^(GKContact *contact) {
ViewControllerA *viewControllerA = [weakSelf.storyboard instantiateViewControllerWithIdentifier:@"ViewControllerA"];
viewControllerA.contact = contact;
viewControllerA.completeBlock = ^(id result) {
weakSelf.segmentedControl.selectedSegmentIndex = 0;
weakSelf.selectedIcon = 0;
[weakSelf reloadTableView];
[weakSelf presentViewController:[[PortraitNavigationController alloc] initWithRootViewController:editVC] animated:YES completion:nil];
};
[self presentViewController:nav animated:YES completion:nil];
}
});
});
我在iPhone 6s和iOS 10.1上运行。有人请帮我解决这个问题。你将节省我生命中的大量时间。感谢。
答案 0 :(得分:0)
谢谢大家帮助我解决这个问题。但是,这个bug已经解决了。
我只需要将密钥NSContactsUsageDescription
添加到文件.plist中。它运作良好。
答案 1 :(得分:0)
在INFO PLIST中添加此内容
Privacy - Contacts Usage Description
AND
NSCalendarUsageDescription