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

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的生命周期那么复杂,只有三个方法
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,578评论 19 139
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,734评论 25 709
  • iOS网络架构讨论梳理整理中。。。 其实如果没有APIManager这一层是没法使用delegate的,毕竟多个单...
    yhtang阅读 10,658评论 1 23
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 47,085评论 6 342
  • 一、条件语句: 条件语句通过设定的一个或多个条件来执行程序,在条件为真时执行指定的语句,在条件为 false 时执...
    Bool吖阅读 3,207评论 0 1