iOS 添加上拉加載

用UITableViewDelegate中的這個(gè)方法:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;

判定tableView中的數(shù)組數(shù)是否即將顯示最后一個(gè)cell,if (indexPath.row == [self.dataArr count]-1)

如果是的話,self.tableView.tableFooterView = footSpinnerView;//footSpinnerView為自定義的UIView,上面加了一個(gè)旋轉(zhuǎn)的UIActivityIndicatorView即可,記得讓UIActivityIndicatorView startAnimation加上刷新數(shù)組的邏輯,取完數(shù)據(jù)后,將self.tableView.tableFooterView設(shè)nil即可。

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

{

? ? if (indexPath.row == [self.productArr count]-1) {

? ? self.tableView.tableFooterView = footSpinnerView;

? ? //添加數(shù)據(jù)源

? ? }

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • 概述在iOS開發(fā)中UITableView可以說是使用最廣泛的控件,我們平時(shí)使用的軟件中到處都可以看到它的影子,類似...
    liudhkk閱讀 9,090評(píng)論 3 38
  • { 24、Sqlite數(shù)據(jù)庫 1、存儲(chǔ)大數(shù)據(jù)量,增刪改查,常見管理系統(tǒng):Oracle、MSSQLServer、DB...
    CYC666閱讀 961評(píng)論 0 1
  • 版權(quán)聲明:未經(jīng)本人允許,禁止轉(zhuǎn)載. 1. TableView初始化 1.UITableView有兩種風(fēng)格:UITa...
    蕭雪痕閱讀 2,919評(píng)論 2 10
  • #pragma mark someValueAboutTableView 1.tableView的樣式:UITab...
    瀟巖閱讀 956評(píng)論 0 0
  • 曾經(jīng)深夜一通電話把對(duì)方叫醒的朋友,曾經(jīng)拉出來擼串喝酒談人生理想的朋友……現(xiàn)在一頓飯,卻永遠(yuǎn)約在“改天”。人和人之間...
    羅掌柜real閱讀 162評(píng)論 0 0