I'm pushing to a `CNContactViewController` for existing contact with `viewControllerForContact` (having set the `contactStore` and the `delegate`, but although I've implemented the `CNContactViewControllerDelegate` methods, they're not getting called. I'm seeing the contact presented fine, but if I tap on any of the properties, I see the following error:
2015-08-13 01:29:38.964 MyApp[2468:869879] plugin com.apple.MobileAddressBook.ContactViewViewService interrupted
2015-08-13 01:29:38.965 MyApp[2468:869879] plugin com.apple.MobileAddressBook.ContactViewViewService invalidated
2015-08-13 01:29:38.978 MyApp[2468:869838] viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
But it never calls my `shouldPerformDefaultActionForContactProperty` delegate method, and after a few seconds the screen goes blank (the contact disappears).
Any ideas?
For the sake of completeness, here is my code:
- (IBAction)didTapButton:(id)sender {
self.store = [[CNContactStore alloc] init];
[self.store requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError *error) {
if (granted) {
NSPredicate *predicate = [CNContact predicateForContactsMatchingName:@"John"];
NSError *error;
NSArray *contacts = [self.store unifiedContactsMatchingPredicate:predicate keysToFetch:@[[CNContactViewController descriptorForRequiredKeys]] error:&error];
NSAssert(contacts, @"%@", error);
NSLog(@"%ld", (long) [contacts count]);
dispatch_async(dispatch_get_main_queue(), ^{
CNContactViewController *controller = [CNContactViewController viewControllerForContact:contacts[0]];
controller.contactStore = self.store;
controller.delegate = self;
[self.navigationController pushViewController:controller animated:TRUE];
});
} else {
NSLog(@"requestAccessForEntityType error: %@", error);
}
}];
}
- (BOOL)contactViewController:(nonnull CNContactViewController *)viewController shouldPerformDefaultActionForContactProperty:(nonnull CNContactProperty *)property {
NSLog(@"%s", __FUNCTION__);
return FALSE;
}
- (void)contactViewController:(nonnull CNContactViewController *)viewController didCompleteWithContact:(nullable CNContact *)contact {
NSLog(@"%@", contact);
}