Mjrefresh refreshing third-party libraries
1. Import Mjrefresh Refresh third-party libraries
2. Import Header File
#import " MJRefresh.h "
3. Implementation of the code (based on an example of a barley mesh)
-(void) mjrefresh{[_tableview addheaderwithtarget:self Action: @selector (Refreshact)]; [_tableview addfooterwithtarget:self Action: @selector (Refreshact)];//[_tableview footerbeginrefreshing];}-(void) refreshact{[self satardown]; [_tableview Reloaddata]; [_tableview headerendrefreshing]; [_tableview footerendrefreshing]; }-(void) satardown{NSString*urlstr =@"http://mapi.damai.cn/proj/HotProj.aspx?CityId=0&source=10099&version=30602"; _dataarray=[[Nsmutablearray alloc]init]; _request=[[HttpRequest alloc]init]; [_request requestwithurl:urlstr target:self Action: @selector (dealdowloadfinish:)]; [_dataarray removeallobjects];}-(void) Dealdowloadfinish: (HttpRequest *) request{nsdictionary*dic =[nsjsonserialization JSONObjectWithData:request.data options:nsjsonreadingmutablecontainers Error:nil]; Nsarray*arr = dic[@"List"]; for(Nsdictionary *appdicincharr) {Appmodel*model =[[Appmodel alloc]init]; Model. Name= appdic[@"Name"]; Model. Summary= appdic[@"Summary"]; Model. ShowTime= appdic[@"ShowTime"]; Model. Venname= appdic[@"Venname"]; Model.cityname= appdic[@"CityName"]; Model. ProjectID= appdic[@"ProjectID"]; Model.pricename= appdic[@"Pricename"]; [_dataarray Addobject:model]; } //End Refresh and Refresh table[_tableview refreshfinished]; [_tableview loadmorefinished]; [_tableview reloaddata];}Code to refer to:
//start refreshing the custom method- (void) setuprefresh{//Drop-down refresh[_tableview addheaderwithtarget:self Action: @selector (headerrereshing) DateKey:@"Table"]; [_tableview headerbeginrefreshing]; //2. Pull Up load more (enter refresh state to invoke Self's footerrereshing)[_tableview addfooterwithtarget:self Action: @selector (footerrereshing)]; //Some settings//Set text (also can not set, default text is modified in mjrefreshconst)_tableview.headerpulltorefreshtext =@"The drop-down can refresh the"; _tableview.headerreleasetorefreshtext=@"release, refresh now."; _tableview.headerrefreshingtext=@"Refresh in ... "; _tableview.footerpulltorefreshtext=@"pull-up can load more data."; _tableview.footerreleasetorefreshtext=@"loosen up and load more data now."; _tableview.footerrefreshingtext=@"Loading in ... ";}//Drop-down refresh- (void) headerrereshing{//in general These are the network requests, then there will be delays, not as fast as the current refresh//1. Add false Data//[_tableviewdata insertobject:@ "This is the refreshed data" atindex:0];[_tableview Reloaddata]; //2. End Refresh[_tableview headerendrefreshing];}//Pull-up loading- (void) footerrereshing{//This is generally the data that extracts the cache//1. Add false Data//[_tableviewdata insertobject:@ "This is the loading of previous data" Atindex://[_tableviewdata Count]];[_tableview Reloaddata]; //2, End refresh[_tableview footerendrefreshing];}
Example download: Download
Reference Link: http://www.iashes.com/2015-01-403.html
Mjrefresh refreshing third-party libraries