ios - 为什么不调用 deinit?

标签 ios swift

这是我的代码。 我不明白为什么不调用 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/

相关文章:

iphone - 在 Xcode 中有条件地链接第三方 API

ios - 如何从 AlamoFire 返回?

ios - 从 Firebase 将图像下载到数组时遇到问题

ios - 如何通过非续订应用内购买支持多台设备?

ios - Google SignIn 完成与手动应用切换

iOS Swift Firebase 存储错误 "No default Storage bucket found"

ios - 如何在 iOS 中将 UIImage 对象添加到 NSMutableArray

swift - 使用 SKView 更改 View ?

swift - 针对特定手势的同时手势识别

ios - 在 Swift 中使用标题中的分段控件更改 UICollectionView 的内容