标签:
方法:
在B页面的控制器中,编写对应的属性,在A页面跳转到B页面的地方,给B的属性赋值即可
//SecondViewController.h @property(nonatomic) NSInteger flag;//当前系统标示(0:其他传值方式;1:block传值方式)
在A页面的试图控制器中
//RootViewController.m - (IBAction)showSecondView:(id)sender { SecondViewController *second = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; second.delegate = self; second.flag = 0; [self presentViewController:second animated:YES completion:nil]; }
主流方案:
(1)通过委托delegate的方式实现
//SecondViewController.h @protocol secondViewDelegate -(void)showName:(NSString *)nameString; @end
设置代理(为防止循环引用,此处采用了weak)
//SecondViewController.h @interface SecondViewController : UIViewController @property (nonatomic, weak)id<secondViewDelegate> delegate; @property (nonatomic, copy) ablock block; @end
转自:http://www.cnblogs.com/JuneWang/p/3850859.html
标签:
原文地址:http://www.cnblogs.com/saurik/p/4940106.html