在故事板,视图和传递数据

Jam*_*sev 11 storyboard xcode4.2

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

  • This one time,我有一个UIButton"愚蠢的名字"
  • In band camp,我有一个UILabel"标签"

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

在此输入图像描述

Lor*_*oog 19

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

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