自定义iWatch App点击Glance后的跳转页

最新版的在iWatch2.0中的点击Glance自定义的界面跳转

到今天为止(2015年11月20日)的官方给出的方法是:

当你的手表app上显示的快速信息浏览界面(Glance界面的时候),如果用户点击了这个界面,默认是跳转到手表app的主界面(也就是默认的InterfaceController界面的),但当你需要重新定义这个过程,希望可以跳转到你指定的界面的时候,按照下面的步骤:

在Glance控制器中:

  • 定义glance,在init和willActivate方法
  • 在Glance被点击的时候(在willActivate方法中),调用updateUserActivity:userInfo:webpageURL:方法,并通过userInfo参数指定传输的信息,在界面跳转的时候,app就会跳转到你指定的界面

例如:

- (void)willActivate {
    // This method is called when the controller is about to be visible to the wearer.
    NSLog(@"%@ will activate", self);

    // Use Handoff to route the wearer to the image detail controller when the Glance is tapped.
    [self updateUserActivity:@"com.example.apple-samplecode.WatchKit-Catalog" userInfo:@{@"controllerName": @"imageDetailController", @"detailInfo": @"This is some more detailed information to pass."} webpageURL:nil];
}

在主控制器(InterfaceController)

  • 实现handleUserActivity:方法,使用提供的userInfo字典定义UI。
    例如:
- (void)handleUserActivity:(NSDictionary *)userInfo {
    // Use data from the userInfo dictionary passed in to push to the appropriate controller with detailed info.
    [self pushControllerWithName:userInfo[@"controllerName"] context:userInfo[@"detailInfo"]];
}

好了,你再次运行试试看吧。

转载于:https://www.cnblogs.com/66it/p/4981666.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值