Mobile Phone APP Run, the value of the transfer between different pages is necessary, there are many ways to pass the value (method transfer value, attribute transfer value, proxy value, single-pass value), here is the main summary of the value of the property and proxy value.
Property pass-through value: The value of the property is the simplest and most common way of transmitting value, but it has limitations (generally used to pass the value of the first page to the second page, but not from the second page to the first page),
Pass value to Secondviewcontroller:secondviewcontroller Set Property SendMessage
1 -(void) Rightbuttonaction: (Uibarbuttonitem *) sender{2 Secondviewcontroller *SECONDVC = [[Secondviewcontroller alloc]init]; 3 Secondvc.sendmessage = Self.rootView.textField.text; 4 [Self.navigationcontroller PUSHVIEWCONTROLLER:SECONDVC animated:yes]; 5 }
Proxy value: Difficult, hard to understand, typically used to pass values to the first page on the second page. Generally divided into six steps
(Example using Navigationcontroller jump page)
1. Statement of Agreement (written on the second page)
@protocol mydelegete <nsobject>-(void) SendMessage: (nsstring*) message; @end
2. Define the properties of the Compliance Agreement (written on the second page) (attributes must be assign )
@property (nonatomic, assign)IDdelegate;
3. Compliance Agreement (written on the first page)
1 @interface <myDelegete>
4. Set proxy (set Agent to write in jump event) (write on first page)
1 -(void ) Rightbuttonaction: (Uibarbuttonitem *) sender{ 2 secondviewcontroller *secondvc = [[ Secondviewcontroller Alloc]init]; 3 secondvc.sendmessage = Self.rootView.textField.text; 4 [Self.navigationcontroller PUSHVIEWCONTROLLER:SECONDVC Animated:yes]; 5 Proxy value Fourth step 6 SECONDVC. delegate = self; 7 8 }
5. Implementing the Protocol Method (written on the first page)
1 -(void) SendMessage: (NSString *) message{2 self.rootView.textField.text = message; 3 }
6. Implement the value of the pass (written on the second page)
1 -(void) Leftbuttonaction: (Uibarbuttonitem *) sender{2 [ Self.navigationcontroller Popviewcontrolleranimated:yes]; 3 // Agent Value Sixth step: 4 [Self. Delegate SendMessage:self.secondView.textField.text]; 5 }
The value of the value of the transfer between IOS pages, agent value