在WatchKit中,prepareForSegue等效 [英] prepareForSegue equivalent in WatchKit

查看:175
本文介绍了在WatchKit中,prepareForSegue等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带2个按钮的界面,它们都调用相同的界面,但信息不同。在传统的界面上我使用prepareForSegue,但我不知道WatchKit上的等价物是什么。

I have an interface with 2 buttons, both of them call the same interface but with different information. On the traditional interface I use prepareForSegue, but I don't know what's the equivalent one on the WatchKit.

推荐答案

你可以做这有两种方式:

You can do this in two ways:

在你的故事板中,你在segue中设置了一个标识符:

In your storyboard you set an identifier in your segue:

然后您可以使用 contextForSegueWithIdentifier

- (id)contextForSegueWithIdentifier:(NSString *)segueIdentifier {
     if ([segueIdentifier isEqualToString:@"yourIdentifier"]) {
        return aDictionaryWithYourInformation;
     }
}

或者您可以通过代码传递上下文信息, with:

Or you can pass information with a context via code, with:

[self pushControllerWithName:@"YourViewController"
                     context:aDictionary];

此上下文是一个字典,您可以在中访问此词典 - (void)awakeWithContext:(id)context

This context is a dictionary and you have access to this dictionary in the - (void)awakeWithContext:(id)context

这篇关于在WatchKit中,prepareForSegue等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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