我有一个rootviewcontroller A,我想删除它,然后设置新的rootviewcontrollerB。但是,当我检查内存时,旧的rootviewcontroller内存尚未释放(deinit),请帮忙,非常感谢。 以下是我的代码:
let appdelegate = UIApplication.shared.delegate as! AppDelegate
let previousViewController = appdelegate.window!.rootViewController
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "identifier")
previousViewController?.dismiss(animated: true, completion: {
previousViewController?.view.removeFromSuperview()
})
appdelegate.window!.rootViewController = newViewController