• 主页
  • ios swift无法关闭视图控制器

ios swift无法关闭视图控制器

我正在打开新的视图控制器,比如

            let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
            let view_controller1 = storyBoard.instantiateViewController(withIdentifier: "incident_view_id") as! IncidentViewController
            let appDelegate = UIApplication.shared.delegate as! AppDelegate
            //self.present(registerViewController, animated: true)
             let navigationController = UINavigationController.init(rootViewController: view_controller1)
            appDelegate.window?.rootViewController = navigationController

它工作得很好,

现在,当我按下一个按钮时,我需要关闭当前视图并返回上一个视图,我很累

self.navigationController?.popToRootViewController(animated: true)

但是不管用,我也试过了

self.view.window!.rootViewController?.dismiss(animated: true, completion: nil)

但是同样的结果。

转载请注明出处:http://www.jxbyjx.net/article/20230502/1180017.html