Home  >  Article  >  Web Front-end  >  Use block to transfer values ​​between two pages_html/css_WEB-ITnose

Use block to transfer values ​​between two pages_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:01:261202browse

The second view declares a block property:

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

Then check whether the block exists in the value transfer method

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

In the main View, when creating the second view, By the way, implement this block

- (IBAction)LoadDetailView:(UIButton *)sender {
[ibTextLabel setText:nil];
DetailViewController *_curDetail = [[DetailViewController alloc] initWithNibName:@ "DetailViewController"
                                                                         *_msg) {
dispatch_async(dispatch_get_main_queue(), ^{
[ibTextLabel setText:_msg];
} );
}];
[self.navigationController pushViewController:_curDetail
🎜>

that's all

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn