如何解散/删除当前的rootViewController,然后弹出新设置的rootviewcontroller

时间:2018-10-14 04:50:00

标签: swift memory-management rootviewcontroller

我有一个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

0 个答案:

没有答案