标签:block实现界面传值
在second的.h文件里面
首先定义一个 BLOCK返回类型为空,参数是你要传的类型这里是NSString
typedef void (^LJFBlock)(NSString *str);
然后声明一个LJFBlock类型测属性(用于下个界面的传参)
@property (nonatomic, copy) LJFBlock block;
然后在second的.m文件里面
里面要出发跳转传值的里面把要传的值self.secondTextField.text通过 self.ljfblock传进来
- (IBAction)backBtnClick:(id)sender {
self.ljfblock(self.secondTextField.text);
[self.navigationController popToRootViewControllerAnimated:YES];
}
其次在First的.m里面
- (IBAction)FirstBtnClick:(id)sender {
SecondViewController *second = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
second.ljfblock = ^(NSString *Str){
self.firstTextField.text = Str;
};
[self.navigationController pushViewController:second animated:YES];
}
如下图所示
标签:block实现界面传值
原文地址:http://blog.csdn.net/tubiebutu/article/details/45287425