这就是我创建和发布自定义 UIWindow 的方式:
class mainViewController: UIViewController {
var customWindow: UIWindow?
override func viewDidLoad() {
super.viewDidLoad()
self.customWindow = UIWindow()
self.customWindow!.rootViewController = UINavigationController(rootViewController: UITableViewController(style: .plain))
self.customWindow!.isHidden = false
}
deinit {
self.customWindow?.rootViewController = nil
self.customWindow?.isHidden = true
self.customWindow = nil
}
}
在deinit
之后,customWindow仍然存在于调试 View 层次结构中,我缺少什么?
最佳答案
以下是工作代码,完全摆脱了 UIWindow 及其兄弟层次结构:
if let rootVC = self.customWindow?.rootViewController {
rootVC.dismiss(animated: false, completion: nil)
self.customWindow = nil
}
关于ios - 自定义 UIWindow 及其根 UINavigationController 未被删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42040177/