这是我创建和发布自定义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仍然存在于调试视图层次结构中,我缺少什么?
答案 0 :(得分:-1)
以下是工作代码,完全摆脱了UIWindow及其兄弟层次结构:
if let rootVC = self.customWindow?.rootViewController {
rootVC.dismiss(animated: false, completion: nil)
self.customWindow = nil
}