【发布时间】:2019-07-22 08:02:57
【问题描述】:
我有一个 ViewController,我通过具有以下功能的 tableviewcell 以编程方式切换到它。
private func switchView(identifier : String){
DispatchQueue.main.async {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: identifier) as UIViewController
self.present(vc, animated: true, completion: nil)
}
}
一段时间后我需要切换回原来的状态,所以我再次用相同的视图调用 switchView。唯一的问题是很多东西在之前的 ViewController 中保持活跃。
如何解除之前的 ViewController 及其所有内容?
【问题讨论】:
-
当你想转到上一个视图时,只需检查标识符并使用 pushviewcontroller 而不是现在。
标签: swift