如何检测 WatchKit 的页面转场中的哪个序列? [英] How to detect which sequence is in page segue for WatchKit?

查看:22
本文介绍了如何检测 WatchKit 的页面转场中的哪个序列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 本教程.

在应用中,两个日历视图显示相同类型的内容.第一个包含今天的活动,滑动显示第二个包含明天的活动.

In the app, both calendar views show the same type of content. The first one contains today's activities, and swiping presents the second one which contains tomorrow's activities.

我想为两个接口控制器重复使用相同的代码(即相同的类).然后,当每个加载时,我需要知道它是哪个,以便显示今天或明天的活动.有没有办法(例如委托方法)来检测它是哪一个?

I'd like to re-use the same code (i.e., same class) for both interface controllers. Then, when each loads, I need to know which one it is, in order to display the activities for today or tomorrow. Is there any way (such as a delegate method) to detect which one it is?

如果没有办法找出来,用所有代码创建一个父类,并为今天和明天的视图创建子类是最好的方法吗?

If there is no way to find out, is it the best way to create a parent class with all the code, and create sub-classes for today and tomorrow views?

推荐答案

一个特定的接口控制器只知道它的上下文,以及它是否被(取消)激活.

All a particular interface controller would know is its context, and whether it's been (de)activated.

由于您没有展示基于模态页面的控制器,因此没有在初始化时传递的上下文来指定特定页面的今天或明天.

Since you're not presenting modal page-based controllers, there's no context which would be passed at initialization to specify today or tomorrow for a particular page.

滑动导航不会将任何上下文从一个页面传递到下一个页面,因此无法识别特定控制器将是哪个当前页面.

The swipe navigation doesn't pass any context from one page to the next, so that doesn't offer a way to identify which current page a particular controller would be.

您需要为今天和明天的界面控制器创建单独的(子)类,并让每个类显示当天的特定数据.

You'll need to create separate (sub)classes for the today and tomorrow interface controllers, and have each display its specific data for that day.

这篇关于如何检测 WatchKit 的页面转场中的哪个序列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆