【发布时间】:2022-03-10 16:53:37
【问题描述】:
我有 3 个视图控制器在第一个视图控制器(即 MydownloadViewController)中,我使用它来推送到另一个视图控制器。
let vc = UIStoryboard.init(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "ImagePreviewViewController") as? ImagePreviewViewController
self.navigationController?.pushViewController(vc!, animated: true)
从图像预览控制器
let vc = self.storyboard?.instantiateViewController(withIdentifier: "DeletePopupViewController") as! DeletePopupViewController
self.present(vc, animated: false, completion: nil)
我想从删除视图控制器返回我的下载视图控制器,为此我正在这样做 -:
self.dismiss(animated: true, completion: {
if let destinationVC = presentingVC.navigationController?.viewControllers.filter({$0 is MyDownloadsViewController}).first {
presentingVC.navigationController?.popToViewController(destinationVC, animated: false)
}
})
但是这段代码出了什么问题,什么也没发生。
【问题讨论】:
-
这行代码是否运行
presentingVC.navigationController?.popToViewController(destinationVC, animated: false)?尝试在该行添加断点。 -
没有这行代码不运行
-
展示VC的是什么?
-
让presentingVC = self.presentingViewController 为! UINavigationController 这是展示 vc @RajaKishan
-
我在打印展示 vc 时发现 nill