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推送到导航堆栈,而不是尝试以模态方式呈现它。
- iOS 11. KVO_IS_RETAINING_ALL_OBSERVERS_OF_THIS_OBJECT_IF_IT_CRASHES_AN_OBSERVER_WAS_OVERRELEASED_OR_SMASHED是什么意思?
- 如何创build转换到SKAction?
- 错误:typesstring的值没有成员componentsSeparatedByCharactersInSet
- UIAlertView标题不显示
- 后台提取不工作
- iOS 5.1和Default.png
- NSTask或相当于iPhone
- UITableViewController的加载方法的逻辑顺序是什么?
- iOS 9 CollectionView放慢速度