本文介绍了在视图控制器之间传递变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此函数在Xcode 4.3中切换视图。

  [self performSegueWithIdentifier:@NextView发件人:自]; 

我想在页面之间传递一些参数。我怎么能这样做?

解决方案

之后执行SegueWithIdentifier:sender:你的view controler将调用

   - (void)prepareForSegue:(UIStoryboardSegue *)segue发送者:(id)sender 
$ b

  if([[segue identifier] isEqualToString:@NextView]){
MyViewController * myVC = [segue destinationViewController];
myVC.propertyToSet = //在此处设置您的房产
}


I am using this function to switch between views in Xcode 4.3.

[self performSegueWithIdentifier:@"NextView" sender:self];

I would like to pass some parameters between pages. How can I do that?

解决方案

After performSegueWithIdentifier:sender: your view controler will call

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

assuming your new view controller has some propertys to set:

if ([[segue identifier] isEqualToString:@"NextView"]) {
    MyViewController *myVC = [segue destinationViewController];
    myVC.propertyToSet = // set your properties here
}

这篇关于在视图控制器之间传递变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 13:53