ios - 从模态中关闭 View Controller

标签 ios swift dismiss navigationcontroller

我有一个带有多个 Controller 的 MainTabBarController。 在我的 FirstTabViewController(嵌入 UINavigationController)中,我推送到另一个 View Controller ,例如:navigationController?.pushViewController(secondViewController, animated: true)

在这个 Controller 中,我必须展示一个模态视图 Controller ,例如:

let vc = self.storyboard!.instantiateViewController(withIdentifier: "SomeViewController") as! SomeViewController

vc.modalPresentationStyle = .overFullScreen
vc.modalTransitionStyle = .coverVertical

let nav = UINavigationController(rootViewController: vc)
self.present(nav, animated: true, completion: nil)

SomeViewController 中,我必须像这样关闭这个 Controller :self.dismiss(animated: true) 但它会自动弹出到 Root View Controller (FirstTabViewController).

我的问题,为什么?

谢谢。

最佳答案

在当前 Controller 而不是 navigationController 上呈现 SomeViewController

所以换行:

self.navigationController?.present(nav, animated: true, completion: nil)

收件人:

self.present(nav, animated: true, completion: nil)

关于ios - 从模态中关闭 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43937559/

相关文章:

ios - Xamarin 表单 : Back to option is covering the app layout when opening the app from test flight or by search

swift - iCloud Drive 问题 : "[DocumentManager] Failed to associate thumbnails for picked URL"

ios - 在标签栏快速使用不同的图标

ios - UNUserNotificationCenter需要willPresent代码

ios - Swift iOS -In ViewWIllAppear 如何检查切换选项卡时 ImagePicker 是否呈现或消失,或者 View 是否被推开/关闭?

iOS 在关闭时从 MPMoviePlayerViewController 的 parentViewController 中调用 void

ios - SQL WHERE IN 子句不起作用 - FMDB - 传递逗号分隔的字符串

ios - 更改 setLineDash :count:phase: to an arc in ios core graphics 中的模式

ios - Xcode 从相机设置按钮图像

android - 如何在不调用 Dismiss 的情况下取消 ProgressDialog?