我在我的应用中展示了一个 CNContactViewController
的实例。我希望用户既可以编辑联系人,也可以关闭此 View Controller 。下面是呈现 View Controller 的代码,它嵌入在 UINavigationController
中。正如您在代码中看到的,我有 allowsEditing = YES
,但是查看屏幕截图;你可以看到我无法编辑。谁能帮我看看我错过了什么?谢谢!
CNContactViewController *contactController = [CNContactViewController viewControllerForUnknownContact:contact];
contactController.allowsEditing = YES;
contactController.delegate = self;
contactController.contactStore = store;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:contactController];
navController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navController animated:YES completion:nil];
编辑:我尝试了@WrightCS 建议的不同方法:
[self presentViewController:contactController animated:YES completion:nil];
并且,一定要添加这个委托(delegate)方法:
- (void)contactViewControllerCNContactViewController *)viewController
didCompleteWithContactCNContact *)contact{
[self dismissViewControllerAnimated:YES completion:nil];
}
但是,反复得到这个错误日志:
[CNUI ERROR] Contact view delayed appearance timed out
不要创建 UINavigationController
实例,而是尝试直接呈现联系人 Controller 。
[self presentViewController:contactController animated:YES completion:nil];
- (void)contactViewControllerCNContactViewController *)viewController
didCompleteWithContactCNContact *)contact;
dispatch_async(dispatch_get_main_queue(), ^{
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:contactController];
navController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navController animated:YES completion:nil];
});
关于ios - 无法编辑或关闭 CNContactViewController (iOS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40566195/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) | Powered by Discuz! X3.4 |