Use block to implement value transfer between two pages, and block to implement two pages

Source: Internet
Author: User

Use block to implement value transfer between two pages, and block to implement two pages

The second view declares a block attribute:

@ Property (nonatomic, copy) void (^ doTransferMsg) (NSString * _ msg );

Then, check whether the block exists in the value passing method.

-(IBAction) transferText :( UIButton *) sender {
If (_ doTransferMsg ){
_ DoTransferMsg (@ "hello there ");
_ DoTransferMsg = nil;
}
[Self. navigationController popViewControllerAnimated: YES];
}

In the main View, this block is implemented by the way when the second view is created.

-(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


JavaScript value transfer between two pages

----- Directly use jsp to upload the file -----
A page needs to be passed with Parameters
B. jsp? A_name =$ {a_name}

Page B
<%
String B _name = request. getParameter ("a_name ");
%>

Value = <% = B _name %>

Pass value between two pages

Use window. open ()
Parent page:
Var child = window. open ("child. aspx "," child "," height = 200, width = 400, status = yes, toolbar = no, menubar = no, location = no ");
<Input type = "hidden" name = "hdvalue" id = "hdvalue">
Subpage:
Optional values opener.doc ument. getElementById ("hdvalue"). value = "value ";
When the page is closed, the above js

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.