如何使用 contextForSegueWithIdentifier 将数据包含在推送序列中?

How do I use contextForSegueWithIdentifier to include data with a push segue?

我的 class 是 class WorkoutSelectorController: WKInterfaceController {,我定义了函数 override func contextForSegueWithIdentifier(segueIdentifier: String) {,我的所有研究都表明在触发推送转场时应该自动调用该函数,以便我可以设置要传递的上下文信息。

但事实并非如此。 push segue 有效,但不调用此方法。更重要的是,我收到错误消息 "Method does not override any method from its superclass",这似乎是在告诉我 WKInterfaceController 不包含 contextForSegueWithIdentifier。但是我查看了 WKInterfaceController.h,它肯定在那里,所以我做错了什么?

为什么说方法不存在?如何在推送转场中包含上下文信息?

你的函数签名有误。正确的签名是来自 documentation.

func contextForSegue(withIdentifier segueIdentifier: String) -> Any?