CNContactViewController对响应者链做了一些奇怪的事情

我试图在我的应用程序中实现UIKeyCommand快捷方式,并且在大多数情况下,它似乎工作正常。 除非我在模态视图中呈现CNContactViewController,它似乎做了一些奇怪的事情:在CNContactViewController被解除后,键盘快捷键仍显示在可发现性HUD中但在整个应用程序中停止工作,即使呈现视图控制器在之后手动调用becomeFirstResponder CNContactViewController被解雇了。

这是来自FirstViewController:

 - (void) showCNContacts { CNContact * contact = [[CNContact alloc] init]; CNContactViewController *createContact = [CNContactViewController viewControllerForNewContact: contact]; createContact.delegate = self; createContact.allowsActions = NO; CNContactStore *store = [[CNContactStore alloc] init]; createContact.contactStore = store; UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:createContact]; navigation.modalPresentationStyle = UIModalPresentationPageSheet; [self presentViewController: navigation animated:YES completion: ^{ NSLog(@"presented CNContactVC - responder = %@", [[[UIApplication sharedApplication] keyWindow] performSelector:@selector(firstResponder)]); }]; } - (void)contactViewController:(CNContactViewController *)viewController didCompleteWithContact:(nullable CNContact *)contact { [viewController dismissViewControllerAnimated:YES completion:^{ [self becomeFirstResponder]; NSLog(@"after dismissing CNContactVC - responder = %@", [[[UIApplication sharedApplication] keyWindow] performSelector:@selector(firstResponder)]); }]; } 

我使用私有API来查看firstResponder ,它正确显示FirstViewController作为第一个响应者。 肯定会调用keyCommands方法也是keyCommands 。 按住Command键会显示可发现性HUD,并显示键盘快捷键。

这显然是Contacts框架的一些错误。 只是不知道如何解决这个问题。 在dispatch_async调用[self becomeFirstResponder]或者在1秒内dispatch_async dispatch_after不起作用。 很想听听一些想法。

谢谢。

我提出的解决方法是将CNContactViewController推送到导航堆栈,而不是尝试以模态方式呈现它。