带有 WatchKit (Watch) 的基于页面的界面中的页码? [英] Page number in Page-Based Interface with WatchKit (Watch)?

查看:24
本文介绍了带有 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.

如果你使用storyboard,也是一样的,你只需要使用另一种方法

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) 的基于页面的界面中的页码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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