什么是小部件生命周期?首先调用哪个函数?
答案 0 :(得分:2)
viewDidLoad()
在视图生命周期中只调用一次。
根据您的需要,使用:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// do stuff you want to do before the view actually appears
}
或:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// do stuff you want to do when the view appears
}
有关UIView
生命周期访问Apples Documentation