ios - 导航栏在取消 "Add to Exsting Contact" Controller 时消失

标签 ios iphone ios9

CNContactViewController for unknowncontact 点击“添加到现有联系人”会显示一个 View Controller 。当用户选择取消时 CNContactViewController 的导航栏消失,现在无法返回。

最佳答案

可能有更好的方法来解决这个问题,但这对我有用。通过将我的 CNContactViewController 实例的导航栏的左侧栏按钮项设置为取消呈现的 CNContactViewController 的取消按钮的新实例来修复。在代码中:

let contactVC = CNContactViewController(forUnknownContact: newContact)
contactVC.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, 
                                                 target: self, action: #selector(cancelAction))

然后我调用present并传入contactVC。然后在cancelAction中我调用了dismiss函数并且它起作用了!

关于ios - 导航栏在取消 "Add to Exsting Contact" Controller 时消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34605594/

相关文章:

ios - 当方法需要很长时间才能完成时如何避免多次调用方法

ios - 如何快速更改 UIbutton 的左半径

ios - 获取存储在远程位置 iOS 9 中的 PDF 文件的缩略图 | swift

ios - View Controller 透明背景

ios - 有时收不到 Pushkit 通知

ios - Xcode 12.4 为模拟器和设备构建,但使用 Pods-MYAPP-frameworks.sh : line 131: ARCHS[@]: unbound variable 归档失败

iphone - UIScrollView滚动检测

iphone - 表头中的按钮用于加载不同的 TableView

ios - 新创建的 Analytics 属性不注册命中 (iOS)

ios - UIPageViewController 与多个 UIViewController 与标题和底栏