在一個(gè)項(xiàng)目開(kāi)發(fā)過(guò)程中為了更好的體驗(yàn)經(jīng)常會(huì)用到下拉刷新更新數(shù)據(jù),當(dāng)然也伴隨一些上拉加載更多數(shù)據(jù)的情況;當(dāng)前比較火的EGOTableViewPullRefresh只實(shí)現(xiàn)了下拉功能,而沒(méi)有上拉的功能。這里介紹一個(gè)同時(shí)集成下拉刷新和上拉加載更多的類庫(kù)EGOTableViewPullRefresh
公司主營(yíng)業(yè)務(wù):網(wǎng)站制作、網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站開(kāi)發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競(jìng)爭(zhēng)能力。創(chuàng)新互聯(lián)建站是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開(kāi)放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來(lái)的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來(lái)驚喜。創(chuàng)新互聯(lián)建站推出三穗免費(fèi)做網(wǎng)站回饋大家。
英文原文和類庫(kù)下載地址:https://github.com/emreberge/EGOTableViewPullRefresh
附帶 Demo效果
容易集成,使用interface builder 添加tableView進(jìn)行配置。
配置簡(jiǎn)單, 箭頭頭像,背景顏色和文本顏色都能通過(guò)PullTableView類的屬性很容易的更改。
上拉加載更多數(shù)據(jù)功能在Table的底部。
可以通過(guò)代碼修改刷新和加載更多動(dòng)畫(huà)。
添加 QuartzCore.framework 到你的工程中。
將 EGOTableViewPullRefresh 拖到你的工程目錄下。
查看 PullTableView.h 文件可用的屬性。
添加一個(gè)PullTableView 到你代碼中,實(shí)現(xiàn)PullTableViewDelegate委托方法。
欣賞吧。
創(chuàng)建一個(gè)新的xcode工程
選擇 View Based Application 模板(xcode 4.2以后版本是 Single View Application模板)
工程名字 EGOTableViewPullRefreshDemo
在工程文件下創(chuàng)建EGOTableViewPullRefreshDemoViewController控制器類(Single View Application模板不需這步)
添加 QuartzCore.framework 到工程中
拖拽 EGOTableViewPullRefresh 目錄下文件到工程支持的文件組下,確保(EGOTableViewPullRefresh)下文件都拷貝到目標(biāo)文件組下。
拖一個(gè)UITableView控件到View視圖上.
打開(kāi) Identity inspector 將Table 的繼承類由 UITableView 改成PullTableView
連接 dataSources數(shù)據(jù)源和 pullDelegate協(xié)議到PullTableView的 File's owner上
添加 #import "PullTableView.h"
聲明 PullTableViewDelegate 和 UITableViewDataSource協(xié)議
創(chuàng)建一個(gè)屬性名為pullTableView的輸出口連接到interface Builder上的tableView上
在.m文件中添加下面代碼
#pragma mark - Refresh and load more methods - (void) refreshTable { /* Code to actually refresh goes here. */ self.pullTableView.pullLastRefreshDate = [NSDate date]; self.pullTableView.pullTableIsRefreshing = NO; } - (void) loadMoreDataToTable { /* Code to actually load more data goes here. */ self.pullTableView.pullTableIsLoadingMore = NO; } #pragma mark - UITableViewDataSource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 5; } - (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 10; } - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if(!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; } cell.textLabel.text = [NSString stringWithFormat:@"Row %i", indexPath.row]; return cell; } - (NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return [NSString stringWithFormat:@"Section %i begins here!", section]; } - (NSString *) tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { return [NSString stringWithFormat:@"Section %i ends here!", section]; } #pragma mark - PullTableViewDelegate - (void)pullTableViewDidTriggerRefresh:(PullTableView *)pullTableView { [self performSelector:@selector(refreshTable) withObject:nil afterDelay:3.0f]; } - (void)pullTableViewDidTriggerLoadMore:(PullTableView *)pullTableView { [self performSelector:@selector(loadMoreDataToTable) withObject:nil afterDelay:3.0f]; }
對(duì)于UI的配置,在ViewDidLoad()方法里面添加下面代碼(比如 修改刷新和上拉的背景色箭頭頭像等)
self.pullTableView.pullArrowImage = [UIImage p_w_picpathNamed:@"blackArrow"]; self.pullTableView.pullBackgroundColor = [UIColor yellowColor]; self.pullTableView.pullTextColor = [UIColor blackColor];
當(dāng)前文章:iOS下拉刷新上拉加載更多EGOTableViewPullRefresh類庫(kù)
文章分享:http://www.chinadenli.net/article8/jogoip.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、Google、標(biāo)簽優(yōu)化、搜索引擎優(yōu)化、外貿(mào)建站、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)