当前位置:网站首页>Using block to realize the traditional values between two pages

Using block to realize the traditional values between two pages

2022-07-06 18:26:00 Full stack programmer webmaster

Hello everyone , I meet you again , I'm the king of the whole stack .

the second view Make a statement block attribute :

@property (nonatomic, copy) void(^doTransferMsg)(NSString *_msg);

Then check in the value transmission method block Does it exist

– (IBAction)transferText:(UIButton *)sender { if (_doTransferMsg) { _doTransferMsg(@”hello there”); _doTransferMsg = nil; } [self.navigationController popViewControllerAnimated:YES]; }

Lord View in . Create a second view When . Realize this by the way block

– (IBAction)LoadDetailView:(UIButton *)sender { [ibTextLabel setText:nil]; DetailViewController *_curDetail = [[DetailViewController alloc] initWithNibName:@”DetailViewController” bundle:nil]; [_curDetail setDoTransferMsg:^(NSString *_msg) { dispatch_async(dispatch_get_main_queue(), ^{ [ibTextLabel setText:_msg]; }); }]; [self.navigationController pushViewController:_curDetail animated:YES]; [_curDetail release]; }

that’s all

Copyright notice : This article is an original blog article , Blog , Without consent , Shall not be reproduced .

Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/117387.html Link to the original text :https://javaforall.cn

原网站

版权声明
本文为[Full stack programmer webmaster]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207061018309129.html