WatchOSAPP生命周期
1.1-簡介
-
WatchOS2.0之后的工程與WatchOS1.0的工程有什么不同之處骤坐?
創(chuàng)建的方式不同
2.0的工程多了一個文件:ExtensionDelegate
-
ExtensionDelegate文件是干嘛用的?
- 用于管理應(yīng)用的生命周期(能夠獨立運行)
WatchOS1.0沒有應(yīng)用的生命周期蔓挖,只有WKInterfaceController的生命周期
-
Controller的生命周期和應(yīng)用的生命周期有什么區(qū)別?
controller的生命周期是管理每一個界面的生命周期
應(yīng)用的生命周期是管理整個App的生命周期
1.2-API
//應(yīng)用加載時會調(diào)用
func applicationDidFinishLaunching() {
// Perform any final initialization of your application.
print(__FUNCTION__)
}
//應(yīng)用激活時會調(diào)用(進入前臺)
func applicationDidBecomeActive() {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
print(__FUNCTION__)
}
//應(yīng)用失活時會調(diào)用(退到后臺)
func applicationWillResignActive() {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, etc.
print(__FUNCTION__)
}
- WatchApp的生命周期沒有iPhoneApp的生命周期那么復(fù)雜媳友,只有三個方法