1. System Control Uirefreshcontrol
How to use:
Only useful for Uitableviewcontroller, unable to pull up refresh, init or viewdidload to create Uirefreshcontrol, set text, color and other information, automatic system Management Uirefreshcontrol, Automatically add to the TableView view, add methods to Uirefreshcontrol, call when the value changes, method for data request, after the request data confirmation is completed, call the Endrefreshing method, close the refresh;
#import "ViewController.h"@interfaceViewcontroller ()@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; [Self Setuprefresh];}/** * Integrated pull -down refresh*/-(void) setuprefresh{//1. Adding a Refresh controlUirefreshcontrol *control=[[Uirefreshcontrol alloc]init]; Control.attributedtitle= [[Nsattributedstring alloc] initwithstring:@"try to load in ..."]; Control.tintcolor=[Uicolor Graycolor]; [Control addtarget:self Action: @selector (Refreshstatechange:) forcontrolevents:uicontroleventvaluechanged]; [Self.tableview Addsubview:control]; //2. Immediately into the refresh state, does not trigger the Uicontroleventvaluechanged event[Control beginrefreshing]; //3. Loading Data[self Refreshstatechange:control];}/** * Uirefreshcontrol into the refresh state: Load the latest data*/-(void) Refreshstatechange: (Uirefreshcontrol *) control{NSLog (@"refreshed the"); [Control endrefreshing];}@endView Code
Drop-down refresh, pull-up load more