Several steps to set up a proxy (1) If a button in a view is clicked, this time you need to refresh the data in the main controller. One way to do this is to have this property of the controller, and then use that property to refresh the data when the button is clicked. Another approach is to set the controller as the proxy for this view, and notify its agent (host controller) to refresh the data when a button in the view is clicked. (2) to become an agent is by the condition, there are several steps 1). Both parties agree on a protocol (proxy protocol, note naming specification), which customizes a protocol in the view, and provides a method in the protocol.
@protocol yyheaderviewdelegate <NSObject>
-(void) Headerviewdidclickheaderview: (Yyheaderview *) Headerview;
@end
2). Add an attribute variable of type ID in the view, and anyone who complies with the agreed protocol can become its proxy.
Delegate adhere to yyheaderviewdelegate this protocol, you can use the method in the Protocol
@property (Nonatomic,weak) id<yyheaderviewdelegate> delegate;
3). In the controller, follow the custom proxy protocol, you can use the method provided by the agent, in this method to refresh the data.
@interface Yyviewcontroller () <YYHeaderViewDelegate>
-(void) Headerviewdidclickheaderview: (Yyheaderview *) Headerview
{
[Self.tableview Reloaddata];
}
4). Set the controller as the agent for the button click event.
headerview.delegate=self;
To set up a proxy