Mjrefresh refreshing third-party libraries

Source: Internet
Author: User

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

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.