UI Basics--(5) Uiviewcontroller, intermediate pass value, forward value, reverse pass value

Source: Internet
Author: User

One, the middle pass value

Global variables

1. Store the median value (delegate--is more troublesome)

@property (Nonatomic,strong) NSString *labeltext;

2. Save the value (put in the Application object)

Yyappdelegate *appdelegate = [UIApplication sharedapplication].delegate;

Appdelegate.labeltext = Label.text;

3. Fetching data

Yyappdelegate *appdelegate = [UIApplication sharedapplication].delegate;

Label.text =appdelegate.labeltext;

Second, forward value

A->b

Local variables

1. Set a property in B to save the value LabelText

@property (Nonatomic,strong) NSString *labeltext;

2. Save value (before VA jumps to VB)

Yygreenviewcontroller *green = [[Yygreenviewcontroller alloc]init];

Green.labeltext = Label.text;

3. Fetch the data and set

Label.text =self.labeltext;

Third, the value of the reverse transmission

Protocol: Proxy (reverse pass value)

A <-b

1. Create the Protocol agent (. h), and declare the method (what to do, with the parameter value-is the value you want to pass),

2. Set the agent properties in B. h

@property (nonatomic,weak) id< Agreement name >delegate;

and ————— stored value (. m) before the interface jumps

[Self.delegate method Name: What to save];

3.A (. h) Compliance Agreement

4. Obtain an agent in (. m),

Yygreenviewcontroller *b = [[Yygreenviewcontroller alloc]init];

B.delegate = self;

5. How to get the value to implement the Protocol (a)

UI Basics--(5) Uiviewcontroller, intermediate pass value, forward value, reverse pass value

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.