UITableView實現下拉刷新添加數據功能

用UITableViewDelegate中的這個方法:

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


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

想在下邊加個視圖的話,可以這麼做:

在UITableView中的tableFooterView裏

self.tableView.tableFooterView = footSpinnerView;//footSpinnerView爲自定義的UIView,上面加了一個旋轉的 UIActivityIndicatorView即可,記得讓UIActivityIndicatorView startAnimation


加上你關於刷新數組的邏輯,如從數據庫中取出更多的數據,取完數據後,將self.tableView.tableFooterView設nil即可。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章