美文网首页
WatchOS系统开发大全(4)-WatchApp生命周期

WatchOS系统开发大全(4)-WatchApp生命周期

作者: 坤小 | 来源:发表于2017-07-27 15:08 被阅读73次

    WatchOSAPP生命周期

    1.1-简介

    • WatchOS2.0之后的工程与WatchOS1.0的工程有什么不同之处?

      • 创建的方式不同

      • 2.0的工程多了一个文件:ExtensionDelegate

    0700.png
    • ExtensionDelegate文件是干嘛用的?

      • 用于管理应用的生命周期(能够独立运行)
    • WatchOS1.0没有应用的生命周期,只有WKInterfaceController的生命周期

    • Controller的生命周期和应用的生命周期有什么区别?

      • controller的生命周期是管理每一个界面的生命周期

      • 应用的生命周期是管理整个App的生命周期

    1.2-API

    
        //应用加载时会调用
        func applicationDidFinishLaunching() {
            // Perform any final initialization of your application.
            print(__FUNCTION__)
        }
        
        //应用激活时会调用(进入前台)
        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__)
        }
        
        //应用失活时会调用(退到后台)
        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的生命周期那么复杂,只有三个方法

    相关文章

      网友评论

          本文标题:WatchOS系统开发大全(4)-WatchApp生命周期

          本文链接:https://www.haomeiwen.com/subject/wsvzkxtx.html