IOS development pull-down refresh and pull-up loading more, ios Loading

Source: Internet
Author: User

IOS development pull-down refresh and pull-up loading more, ios Loading
IOS development pull-down refresh and pull-up loading more 1. Introduction to common pull-down refresh and pull-up loading more implementation methods

(1) UIRefreshControl

(2) EGOTableViewRefresh

(3) AH3DPullRefresh

(4) MJRefresh

(5) self-implementation

 

2. Use 2.1 configuration of AH3DPullRefresh

1. Import the AH3DPullRefresh project file

2. Go to the project TARGETS-> Build Phases-> Compile Sources->

Search UIScrollView + AH3DPullRefresh and add "-fno-objc-arc"

3. Add the header file UIScrollView + AH3DPullRefresh

#import "UIScrollView+AH3DPullRefresh.h"
2.2 usage (full-seat network-based instances)

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

# Pragma mark pull-down refresh and pull-up load more-(void) addPullRefreshAndPullLoadMore {[_ tableView setPullToRefreshHandler: ^ {// start download_offset = 1 from the first line of data; [self startDownloadData];}]; [_ tableView setPullToLoadMoreHandler: ^ {_ offset + = _ pageSize; [self startDownloadData];}

2. download data: if it is a pull-down refresh, clear all data first.

// If _ offset = 1, refresh if (_ offset = 1) {[_ dataArray removeAllObjects];}

After loading the new data, refresh and refresh the table.

// Stop refreshing [_ tableView refreshFinished]; [_ tableView loadMoreFinished]; [_ tableView reloadData];

3. 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: 0 error: nil]; NSArray * list = [doc nodesForXPath: @ "// promotion" error: nil]; // If _ offset = 1, refresh if (_ offset = 1) {[_ dataArray removeAllObjects];} for (GDataXMLElement * promotion in list) {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

Related Article

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.