Sug*_*n S 9 objective-c uitableview uiactivityindicatorview ios
我有UITableview一个分页,如第一个将从服务器获得20个对象,并将填充在UITableView它到达最后一行时需要进行另一个服务调用,以获得接下来的20个对象.
我的问题是我需要在我的表底部添加活动指示器并且应该说"正在加载",用户可以向上滚动以查看当前对象但不应向下滚动.
有自定义控件吗?有没有最好的方法来实现它?
提前致谢.
Nat*_*jan 27
让我们试试TableView Footer View来显示活动指标.
例如 :
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];
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
| 归档时间: |
|
| 查看次数: |
12042 次 |
| 最近记录: |