【发布时间】:2017-02-09 16:19:54
【问题描述】:
我有一个已经连接在 InterfaceBuilder 中的按钮,用于调出模态界面控制器。在某些情况下,我想以编程方式触发此转换,但我找不到在 Watchkit 中执行相同转场的方法。我知道你可以在 iphone/iOS 中做到这一点,但到目前为止我在 Watchkit 中找不到它。
【问题讨论】:
标签: segue watchkit apple-watch
我有一个已经连接在 InterfaceBuilder 中的按钮,用于调出模态界面控制器。在某些情况下,我想以编程方式触发此转换,但我找不到在 Watchkit 中执行相同转场的方法。我知道你可以在 iphone/iOS 中做到这一点,但到目前为止我在 Watchkit 中找不到它。
【问题讨论】:
标签: segue watchkit apple-watch
它可以以编程方式完成。您需要在 StoryBoard 中为界面设置 Identifier。
如果你希望它以模态方式呈现
presentControllerWithName("Identifier", context: nil)
如果你想推
pushControllerWithName("Identifier", context: nil)
您可以根据需要设置上下文。您可以在您推送/呈现的控制器中检索它
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
}
【讨论】:
新来电:
presentController(withName: "Identifier", context: nil)
pushController(withName: "Identifier", context: nil)
【讨论】: