To set up a proxy

Source: Internet
Author: User
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

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.