申明:此为本人学习笔记,若有纰漏错误之处的可留言共同探讨
#pragma mark - buttonClick
- (IBAction)myButton:(UIButton *)sender
{
NextViewController *next = [[NextViewController alloc]init];
[self presentViewController:next animated:YES completion:nil];
// 初始化
next.myBlock = ^void(NSString* string)
{
self.myLabel.text = string;
};
}
VC2
// 声明
@property(nonatomic,strong)void(^myBlock)(NSString*);
#pragma mark - buttonClick
- (IBAction)myButton:(UIButton *)sender
{
// 调用
_myBlock(self.myLabel.text);
[self dismissViewControllerAnimated:YES completion:nil];
}