这是我的代码。 我不明白为什么不调用 deinit。
class SplashVC: UIViewController {
init() {
super.init(nibName: nil, bundle: nil)
print("SplashVC created")
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
DispatchQueue.main.asyncAfter(deadline: .now() + 2) { [weak self] in
self?.navigationController?.popViewController(animated: false)
self?.navigationController?.pushViewController(SignupViewController(), animated: true)
}
}
deinit {
print("SplashVC free")
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
最佳答案
我阅读了文档,现在我知道弹出 Root View Controller 是我的问题。
This method removes the top view controller from the stack and makes the new top of the stack the active view controller. If the view controller at the top of the stack is the root view controller, this method does nothing. In other words, you cannot pop the last item on the stack
关于ios - 为什么不调用 deinit?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58319930/