我有一个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及其所有内容?
答案 0 :(得分:0)
您是否尝试过在要摆脱的VC上调用“ dismiss”?
self.dismiss(animated: true, completion: {
let vc = FirstController()
pvc?.present(vc, animated: true, completion: nil)
})