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的生命周期那么复杂,只有三个方法
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值