03-UIKit, forward and reverse value transfer between VC, proxy

Source: Internet
Author: User

: It is to pass the value of the first interface to the second interface for display. Its simple implementation method is as follows:

// Create the second VC
TRsceondViewController * sceondViewController = [[TRsceondViewController alloc] initWithNibName: @ "TRsceondViewController" bundle: nil];
// Sets the second VC effect.
SceondViewController. modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
// Send the text value to the public attribute message in the second VC. The label in the second VC cannot be directly accessed.
SceondViewController. message = self. sendField2.text;
// Jump to the created VC interface
[Self presentViewController: sceondViewController animated: YES completion: nil];

}

: Click a button on the first interface to jump to the second interface. Then, return the value of the second interface to the first interface and display it. Its simple implementation method is as follows:

Self. firstViewCtroller. userInputMessage = self. textField. text;
// After this statement is executed, dealloc is called to release TRSecondViewController.
[Self dismissViewControllerAnimated: YES completion: nil];
}

: In reverse value passing, we know that the second interface (the entrusting party) can return a value to the first interface. If there are a lot of values that need to be obtained from the entrusting party like the first interface, we know that in the entrusting party, we have a property that can receive a fixed interface property. If there are multiple properties, we cannot write multiple such properties. This is obviously inappropriate, here we need to use the Protocol to solve this problem. The specific method is as follows:

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.