本文介绍了使用WatchKit(Watch)的基于页面的界面中的页码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用。

共有3页,每一页都连接到我的 InterfaceController.swift 类(扩展 WKInterfaceController )。

There are 3 pages and each one is connected to my InterfaceController.swift class (which extends WKInterfaceController).

我的问题:在InterfaceController.swift里面如何检测页面当前视图的编号?

My question: inside InterfaceController.swift how can I detect the page number of the current view?

推荐答案

如果您使用

func presentControllerWithNames(_ names: [AnyObject],
                   contexts contexts: [AnyObject]?)

您只需要在上下文中传递页面编号,这样您就可以存储它,并在以后检索它。这是非故事板方式。

You just have to pass the number of the page in the context, so you can store it, and retrieve it later on. This is the non storyboard way.

如果你使用故事板,它是一样的,你只需要使用其他方法

If you use storyboard, it is the same, you just have to use the other method

func contextsForSegueWithIdentifier(_:inTable:rowIndex:)

并在每个控制器的上下文中传递您的页面索引

And pass your page index in the context of each controller

这篇关于使用WatchKit(Watch)的基于页面的界面中的页码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 18:21