用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ù)源
? ? }
}