swift - 如何使用 contextForSegueWithIdentifier 将数据包含在推送转场中?

标签 swift inheritance segue watchkit

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

但事实并非如此。推送转场有效,但不调用此方法。更重要的是,我收到错误消息“方法不会覆盖其父类(super class)中的任何方法”,这似乎告诉我 WKInterfaceController 不包含 contextForSegueWithIdentifier。但我查看了 WKInterfaceController.h,它肯定在那里,那么我做错了什么?

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

最佳答案

您的函数签名错误。正确的签名是 documentation 中的 func contextForSegue(withIdentifier segueIdentifier: String) -> Any? .

关于swift - 如何使用 contextForSegueWithIdentifier 将数据包含在推送转场中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52762022/

相关文章:

iphone - 在 swift 中将数据从一个 View Controller 传递到下一个 View Controller 而无需转场

swift - 使用 segue 的 datePicker 日期

ios - 以编程方式快速将单元格 textLabel 对齐到左上角

ios - Swift:addSubview 未出现在 View 层次结构中

ios - String.subscript.getter 的 NSRangeException

swift - 为所有对象重置核心数据 bool

javascript - 使用 Babel 扩展 Date 类

JavaScript继承: How can we inherit object and function where object is created from function using new operator and has prototype functions

c++ - 继承加法赋值操作,如何返回正确的类型?

swift - 如何防止按钮在每次点击时反复运行?