gpt4 book ai didi

ios - viewDidLoad() 和 viewDidAppear() 只调用一次?

转载 作者:行者123 更新时间:2023-11-29 05:24:03 26 4
gpt4 key购买 nike

这是我的 ViewController(其他文件没有更改):

import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
print("hi from vdl")
}

override func viewDidAppear(_ animated: Bool) {
print("hi from vda")
}

}
  1. 我按下 xCode 中的三角形(“构建然后运行当前方案”)并获得输出:

hi from vdl
hi from vda

  1. 现在,我转到主屏幕,从模拟器左侧滑动,然后将应用程序滑出。输出:

Message from debugger: Terminated due to signal 9

  • 现在我从模拟器启动应用程序(单击主屏幕中的图标)。应用程序启动但没有输出。为什么 ?我需要从 xCode 重新运行应用程序才能获取输出。
  • 最佳答案

    当您在模拟器中关闭应用程序时,您会断开与调试器的连接。

    附言您没有在 viewDidAppear 中调用 super

    关于ios - viewDidLoad() 和 viewDidAppear() 只调用一次?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58370591/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com