How to detect which sequence is in page segue for WatchKit?

╄→尐↘猪︶ㄣ 提交于 2019-12-24 18:13:50

问题


I'm trying to implement a page-based navigation app using the "Next Page Relationship Segue" described in this tutorial.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/36255075/how-to-detect-which-sequence-is-in-page-segue-for-watchkit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!