在UITableView的底部添加活动指标?

我有UITableview分页像第一个将从服务器获得20个对象,将填充UITableView然后当它到达最后一行需要进行另一个服务调用,以获得下20个对象。我的问题是我需要添加活动指标在我的表底部并应该说“加载”,用户可以滚动到查看当前的对象,但不应该向下滚动。是否有任何自定义控件? 有没有最好的办法来实现它?。提前感谢。

让我们尝试TableView页脚视图来显示活动指标。

例如 :

声明UIView * footerView; 在.h文件中

在.m文件中添加以下方法

- (void)viewDidLoad { [super viewDidLoad]; [self initFooterView]; } -(void)initFooterView { footerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 40.0)]; UIActivityIndicatorView * actInd = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; actInd.tag = 10; actInd.frame = CGRectMake(150.0, 5.0, 20.0, 20.0); actInd.hidesWhenStopped = YES; [footerView addSubview:actInd]; actInd = nil; } -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { BOOL endOfTable = (scrollView.contentOffset.y >= ((self.contentArray.count * 40) - scrollView.frame.size.height)); // Here 40 is row height if (self.hasMoreData && endOfTable && !self.isLoading && !scrollView.dragging && !scrollView.decelerating) { self.tableView.tableFooterView = footerView; [(UIActivityIndicatorView *)[footerView viewWithTag:10] startAnimating]; } } 

谢谢!

看看这个开源项目。它可以帮助你…

https://github.com/dkSolutions/DKPaginatedTableView