在故事板上,视图和传递数据 [英] On storyboards, views and passing data along

查看:28
本文介绍了在故事板上,视图和传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Xcode 4.2 故事板中,我有 2 个 UIViewControllersThis one timeIn band camp

In my Xcode 4.2 storyboard, i have 2 UIViewControllers, This one time and In band camp

  • 这一次中,我有一个带有傻名字"的UIButton
  • In band camp中,我有一个带有label"的UILabel
  • In This one time, i have a UIButton with "silly name" on it
  • In In band camp, i have a UILabel with "label" on it

考虑到我们正在处理 2 个独立的类 AND 我们在 Xcode 4.2 中使用 storyboards(其中设置了视图之间的转换通过 segue)我如何将愚蠢的名字"从视图控制器 This one time 传递到视图控制器 In band camp 中的标签?"

Considering that we're dealing with 2 separate classes AND we're in Xcode 4.2 using storyboards (where transition between views is setup via a segue) how can i pass "silly name" from view controller This one time to the label in view controller In band camp?"

推荐答案

  1. 将storyboard中segue的标识符设置为AwesomeSegue"
  2. 实现 prepareForSegue 方法
  3. 在方法内部,检查segue的标识符是否与AwesomeSegue"匹配——如果是,使用destinationViewControllerObject

  1. Set the identifier of segue in storyboard to "AwesomeSegue"
  2. Implement prepareForSegue method
  3. Inside the method, check if identifier of segue matches "AwesomeSegue" - if yes, use the destinationViewControllerObject

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"AwesomeSegue"]) {
        InBandCampViewController *ibcVC = [segue destinationViewController];
        ibcVC.yourData = self.someStuff;
    }
}

这篇关于在故事板上,视图和传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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