我有7个屏幕(VC)的应用程序,嵌入在导航控制器中。
我有一个未嵌入的独立VC。这个VC的作用类似于自定义弹出式class PopupView: UIViewController {}
,并通过我的应用程序中使用自定义segue(在故事板中设置为自定义segue)的每个屏幕按下按钮来调用:
open class MIBlurPopupSegue: UIStoryboardSegue {
open override func perform() {
MIBlurPopup.show(destination, on: source)
} }
在这个弹出窗口中,有一个按钮可以打开嵌入导航堆栈中的另一个VC(VC始终相同)。
我想要实现的是通过按下Popup VC中的按钮实际打开导航堆栈中的VC,然后返回到调用Popup的屏幕。
所以,用户旅程看起来像 - 打开VC1(2,3,5,6,7) - >调用弹出VC - >按下按钮 - >打开VC4 - >按导航返回按钮 - >返回VC1。
我现在拥有的东西:
performSegue(withIdentifier: "toVC4")
,present(vc, animated: true, completion: nil)
let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "VC4")
self.present(controller, animated: true, completion: nil)
我肯定错过了一些东西,如果有人能提供代码示例来解决这个问题,我将非常感激。
您可以在弹出按钮的操作中尝试此操作
self.dismiss(animated:true) {
if let nav = UIApplication.shared.keyWindow?.rootViewController as? UINavigationController {
let vc1 = storyboard!.instantiateViewController(withIdentifier: "MenuId")
let finalVC = storyboard!.instantiateViewController(withIdentifier: "finalId")
nav.setViewControllers([vc1,vc4],animated:true) // set it to false if you want
}
}