Apple Watch Kit(1)- 开发一瞥

Watch Kit 开发一瞥

创建项目

  • 一下是在已经创建的iphone app的基础上进行的操作:

    • 1、添加target

    • 2、选择WatchKit App

    • 3、填写Target信息,此处可以选择是否支持 Notification 和 Glance。

Watch App 的运行机制

创建完项目后我们可以看到多出了来两个group 这个两个group 分别是WatchKit Extension和WatchKit App.   WatchKit Extension 即 运行在iphone上的WatchKit App的辅助程序,主要用来处理事件数据等,  WatchKit App     运行在apple watch 上程序,用于展示。
  • watch app 的加载机制,如下图:

  • watchkit 的 interface controller 的生命周期: 如下图:

  • 三种接口类型的实现

    • The WatchKit App

            ///数据初始化
            - (instancetype)init
            {
                self = [super init];
                if (self) {
                    //Fetch the data you want to display.
                }
                return self;
            }
      
      
            ///页面布局参数设置
            - (void)awakeWithContext:(id)context {
                [super awakeWithContext:context];
      
      
                //Set the initial values and configuration of labels, images, and other controls. Configure interface objects here.
      
      
                NSLog(@"%@ awakeWithContext", self);
      
      
            }
      
      
            ///当controller将显示在屏幕上的时候调用
            - (void)willActivate {
                // This method is called when watch view controller is about to be visible to user
                NSLog(@"%@ will activate", self);
            }
      
      
            ///当controller即将不显示在屏幕上的时候调用
            - (void)didDeactivate {
                // This method is called when watch view controller is no
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值