swift - iOS Swift : Dismiss View Controller That Was Presented Using "Show Detail"

标签 swift uiviewcontroller uinavigationcontroller

我有一个嵌入在导航 Controller 中的 View Controller 。我在 Storyboard中使用显示细节来显示它。我将如何关闭此 View Controller 或返回上一个?

我知道使用“显示详细信息”时会自动返回功能,但我需要将此功能嵌入到导航 Controller 中,该 Controller 不允许返回功能,因此我需要放置一个“取消”栏按钮,但它不起作用。我尝试了这些方法但没有奏效:

    dismiss(animated: true, completion: nil)
navigationController?.popViewController(animated: true)
self.presentingViewController?.dismiss(animated: true, completion: nil)

最佳答案

您可以从细节 Controller 向主 Controller 添加一个展开转场。

在您的主 Controller 中,添加一个处理展开操作的方法:

@IBAction func unwindFromDetail(segue: UIStoryboardSegue) {

}

然后在storyboard中,控制从detail controller拖拽到master controller的“Exit”,然后选择上面的方法。

给 segue 一个标识符并执行它!

关于swift - iOS Swift : Dismiss View Controller That Was Presented Using "Show Detail",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51459744/

相关文章:

ios - 在 View Controller 中快速加载 Collection View Controller

ios - Swift ios导航栏在被滚动隐藏后不会出现

iphone - 弹出一个基本 View 。它会弹出所有 subview 吗?

xcode - 在上一个 View 上居中弹出窗口

ios - 防止一个 View Controller 自动旋转?

ios - 在 iOS 中推送 View Controller 时难以绕过堆栈中的 View Controller

ios - 没有导航 Controller 的 pushViewController

ios - 我如何在替换旧的 Storyboard上使用相同的 UIViewController

swift - 打开应用程序商店,但链接不起作用

json - Swift .flatMap 未将 json 数据初始化为结构