This is my ViewController (no changes to other files):
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
print("hi from vdl")
}
override func viewDidAppear(_ animated: Bool) {
print("hi from vda")
}
}
hi from vdl
hi from vda
Message from debugger: Terminated due to signal 9
When you close the app in simulator, you break the connection with the debugger.
PS You didn't call super
in viewDidAppear
.
viewDidLoad()
and viewDidAppear()
work when you get in a VC(ViewController),like present,push,pop,dismiss.
When a VC is presented or pushed to other VC, viewDidLoad()
and viewDidAppear()
will work.And when you pop/dismiss a VC,the previous VC shows up which make viewDidAppear()
work.
But Move to home screen doesn't make effect on the two.
If you want to know when the app will enter the background,use the func applicationDidEnterBackground(_ application: UIApplication)
in AppDelegate.swift
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.