IOS applicationWillResignActive挂起
/*
//UIApplicationDelegate委托代理方法
1.程序开始:didFinishLaunchingWithOptions:程序开始
2.程序挂起:applicationWillResignActive
3.程序复原(程序重新激活):applicationDidBecomeActive
注意:应用程序在启动时,在调用了 applicationDidFinishLaunching 方法之后也会调用 applicationDidBecomeActive 方法,所以你要确保你的代码能够分清复原与启动,避免出现逻辑上的bug。
4.程序意外暂行(终止):applicationWillTerminate
5.程序进入后台:applicationDidEnterBackground
6.程序进入前台:applicationWillEnterForeground
//调用方法场景
首次运行:
didFinishLaunchingWithOptions//程序开始
applicationDidBecomeActive//程序复原(程序重新激活)
首次关闭(home):
applicationWillResignActive//程序挂起
applicationDidEnterBackground//程序进入后台
再次运行:
applicationWillEnterForeground//程序进入前台
applicationDidBecomeActive//程序复原(程序重新激活)
再次关闭:
applicationWillResignActive//程序挂起
applicationDidEnterBackground//程序进入后台
*/
func applicationWillResignActive(_ application: UIApplication) {
application.applicationIconBadgeNumber = 0;
print("程序挂起")
}
func applicationDidBecomeActive(_ application: UIApplication) {
print("程序复原")
}
func applicationWillTerminate(_ application: UIApplication) {
print("程序终止")
}
func applicationDidEnterBackground(_ application: UIApplication) {
print("程序进入后台")
}
func applicationWillEnterForeground(_ application: UIApplication) {
print("程序进入后台")
}