iOS is a lot of page-passing methods, this blog is mainly through the delegation mode to pass value. Pass the value of the time picker in one page to another page
Consists of three main modules
First: Class A
Second: Trust agreement
Third: Class B
First define a delegate uiviewpassvaluedelegate to pass the value
@protocol viewpassvaluedelegate <nsobject>-(void) Passvalue:( NSString *) value; @end
Declare the delegate in Class A, and implement the delegate
@property (nonatomic, unsafe_unretained) id<viewpassvaluedelegate> delegate;
Send Agent
Trajectoryviewcontroller *acceptcontroller = [[Trajectoryviewcontroller alloc] init];//instantiates an object of view 2 Delegte = Acceptcontroller; Send the agent and pass the values in the text box [Delegte passvalue:string1];
Class B Declaration Delegate
#import <UIKit/UIKit.h> #import <ViewPassValueDelegate.h> @interface Acceptviewcontroller: Uiviewcontroller<viewpassvaluedelegate> @end
The Protocol method that must be implemented is used to pass values
-(void) Passvalue: (NSString *) value{ NSLog (@ "Passvalue method Get value%@", value);}
Transfer values between IOS delegate pages