IOS:ActivityIndicator超过UITableView ......怎么样? [英] IOS: ActivityIndicator over UITableView... How to?
本文介绍了IOS:ActivityIndicator超过UITableView ......怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望在加载数据时(在另一个线程中)在uitableview上显示活动指示符。所以在UITableViewController的ViewDidLoad方法中:
i want display an activity indicator over a uitableview while it's loading data (in another thread). So in the ViewDidLoad method of the UITableViewController:
-(void)viewDidLoad
{
[super viewDidLoad];
//I create the activity indicator
UIActivityIndicatorView *ac = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[ac startAnimating];
//Create the queue to download data from internet
dispatch_queue_t downloadQueue = dispatch_queue_create("PhotoDownload",NULL);
dispatch_async(downloadQueue, ^{
//Download photo
.......
.......
dispatch_async(dispatch_get_main_queue(), ^{
......
......
[ac stopAnimating];
});
});
.......
为什么活动指示器不显示在表视图?我怎样才能实现它?
Why the activity indicator don't display over the table view? How can i achieve it?
推荐答案
您需要添加UIActivityIndicatorView。您可以将其添加到UITableView标头视图中。为此,您需要提供自己的自定义视图。
You need to add the UIActivityIndicatorView to something. You can add it to a UITableView header view. To do this you will need to provide your own custom view.
...
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
[view addSubview:ac]; // <-- Your UIActivityIndicatorView
self.tableView.tableHeaderView = view;
...
这篇关于IOS:ActivityIndicator超过UITableView ......怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文