ios - swift 3 : Dismiss popup ViewController

标签 ios swift swift3 viewcontroller

<分区>

我在解雇 VC 时遇到了一些问题。

我的项目有 2 个 View Controller 。 View Controller A 和 View Controller B。

Viewcontroller A 有一个按钮。如果我按下这个按钮,第二个 ViewController B 会弹出。

第二个 ViewController (B) 有一个按钮。 如果我单击此按钮,此操作将开始:

    @IBAction func dismiss(_ sender: UIBarButtonItem) {

    self.presentedViewController?.dismiss(animated: true, completion: nil)

}

此操作实际上应该关闭 Viewcontroller 并再次显示 Viewcontroller A。

但是如果我按下这个按钮没有任何反应。

我是不是忘记了什么?

最佳答案

应该是:

@IBAction func dismiss(_ sender: UIBarButtonItem) {
    self.dismiss(animated: true, completion: nil)
}
Viewcontroller B

presentedViewController 为 nil,这就是什么都没有发生的原因。 Viewcontroller ApresentedViewController 是您的 Viewcontroller B

关于ios - swift 3 : Dismiss popup ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43481344/

相关文章:

ios - 如何使多个右栏按钮项目在导航栏中垂直堆叠?

ios - 使用 SDWebImage 从视频 URL 获取缩略图

swift - 通用功能中未识别协议(protocol)一致性

swift - 如何打印节点名称

ios - 关闭模态视图 Controller 偶尔会卡住应用程序,swift 3

iOS : Xcode Crash when configure SVN

ios - 当点击单元格中的 UIImageView 时如何获取indexpath.row?

ios - 如何检查 AV 播放器何时在 swift 3 中达到特殊秒数

swift - 带有自定义表格 View 单元格的表格 View 在滚动时消失

ios - 如何实现自定义 AWSCredentialsProvider