Agent: Also called to entrust oneself can not do things entrusted to others to do
Uialertview Uitextfield, who had previously learned, used proxies.
Reverse Value Proxy proxy block
Steps to write an agent
Someone who needs help (the person who is asking for help on behalf of the meal)
1. Declare the protocol method inside the agent (
@protocol)
2. Declaring the properties of an agreement
3. When to trigger this proxy method
4. Invoking the Proxy method through the properties of the Agreement (delegate)
A helping hand (a person who helps bring a meal)
5. Import Agreement
6. In the initialization of the agent method of the place, hang up the agent (promised to help bring rice)
7. Write the proxy method waiting to be executed
1. Affirm the proxy method (do not declare the proxy method in @interface)
@protocol nextdelegate <NSObject>
-(void) Tologinwithname: (NSString *) name;
@end
2. Declare the properties of the agent (which can be found through the properties of proxy methods) in @interface
@property (nonatomic,assign) id<nextdelegate>delegate;
The properties of the claims agent are assigned to the stack with assign
Type of Id<nextdelegate>delegate Agent < name of Agent >
@property (nonatomic,copy) NSString *titlename;
3. When to trigger this proxy method
-(void) torigether{
Trigger Proxy method After clicking Register successful
4. Call this proxy method via the properties of the Protocol (delegate)
[Self.delegate tologinwithname:@ "Gourd Doll"];
[Self.navigationcontroller Poptorootviewcontrolleranimated:yes];
}
5. Import Agreement
@interface Viewcontroller () <NextDelegate,UIActionSheetDelegate>
@end
6. Attach the Agent
Next.delegate = self;
7. Write the agent method waiting to be executed (the action of the person who buys the food)
-(void) Tologinwithname: (NSString *) name{
NSLog (@ "%@ login succeeded", name);
}
2. Wait view
Indicator =[[uiactivityindicatorview Alloc]initwithactivityindicatorstyle:uiactivityindicatorviewstylewhitelarge ];
Indicator.color = [Uicolor redcolor
];
Indicator.center = Self.view.center;
[Indicator startanimating];
[Self.view Addsubview:indicator];
/3. Pop-Up Box selection button
Uiactionsheet * Acttionsheet = [[Uiactionsheet alloc]initwithtitle:
@ "Choose??" Delegate:self cancelbuttontitle:@ "Cancel" destructivebuttontitle:@ "Caution point" otherbuttontitles:@ "no?", nil];
IOS-7-Step Learning Agency