Under iOS development pull refresh and pull up load more

Source: Internet
Author: User

Under iOS development pull-up and pull-up loads more 1. Introduction to common drop-down refreshes and pull-up loads more implementations

(1) Uirefreshcontrol

(2) Egotableviewrefresh

(3) Ah3dpullrefresh

(4) Mjrefresh

(5) Self-realization

Use of the 2.ah3dpullrefresh 2.1 configuration

1. Import Ah3dpullrefresh project files

2. In the engineering targets-> Build phases-> Compile sources->

Search for Uiscrollview+ah3dpullrefresh and add "-fno-objc-arc" to the back

3. Add header Uiscrollview+ah3dpullrefresh header file

#import " uiscrollview+ah3dpullrefresh.h "
2.2 Use (example based on a full net)

1. Add drop-down refresh and pull-up load more methods

#pragma Mark drop-down refresh and pull-up load more-(void) addpullrefreshandpullloadmore{    [_tableview Setpulltorefreshhandler:^{        // starting from the first row of data download        1;        [Self startdownloaddata];    }];        [_tableview setpulltoloadmorehandler:^{        + = _pagesize;        [Self startdownloaddata];}    ];}

2. Download the data: If it is a drop-down refresh first clear all the data

// If _offset = 1, refresh again    if 1 ) {               [_dataarray removeallobjects];    }

End Refresh and Refresh table after loading complete new data

// End Refresh     [_tableview refreshfinished];    [_tableview loadmorefinished];    [_tableview Reloaddata];

3. The complete code:

-(void) startdownloaddata{NSString*urlstr =[NSString stringwithformat:main_shop_url,_city,_categotry,_offset,_pagesize]; _reauest=[[HttpRequest alloc]init]; [_reauest requestwithurl:urlstr targe:self Action: @selector (dealdownloadfinish:)];}-(void) Dealdownloadfinish: (HttpRequest *) request{NSString*str =[[NSString Alloc]initwithdata:request.data encoding:nsutf8stringencoding]; NSLog (@"%@", str); Gdataxmldocument*doc = [[Gdataxmldocument alloc]initwithdata:request.data options:0Error:nil]; Nsarray*list = [Doc Nodesforxpath:@"//promotion"Error:nil]; //If _offset = 1, refresh again    if(_offset = =1) {[_dataarray removeallobjects]; }         for(Gdataxmlelement *promotioninchlist) {Promotionmodel*model =[[Promotionmodel alloc]init]; Model.myid= [[[[Promotion Elementsforname:@"ID"] firstobject] stringvalue]; Model.name= [[[[Promotion Elementsforname:@"name"] firstobject] stringvalue];    [_dataarray Addobject:model]; }        //End Refresh[_tableview refreshfinished];    [_tableview loadmorefinished];    [_tableview Reloaddata]; }

    

Download

Under iOS development pull refresh and pull up load more

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.