iewCell时设置UIActivityIndi​​catorV

iewCell时设置UIActivityIndi​​catorV

本文介绍了如何在加载UITableViewCell时设置UIActivityIndi​​catorView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个 UITableViewController s,A和B.当我点击表A中的一个单元格时,我将使用 UINavigationController 推送表视图控制器B.但B的数据是从Internet下载的,需要几秒钟。所以我想在加载B时添加 UIActivityIndi​​catorView 。我怎样才能实现这个目标?

I have two UITableViewControllers, A and B. When I tap one cell in table A, I will use UINavigationController to push table view controller B. But the data of B is downloaded from Internet, which takes several seconds. So I want to add a UIActivityIndicatorView when loading B. How can I achieve this?

推荐答案

您可以将 UIActivityIndi​​catorView 添加为单元格的 accessoryView

You can add UIActivityIndicatorView as cell's accessoryView.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    spinner.frame = CGRectMake(0, 0, 24, 24);
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    cell.accessoryView = spinner;
    [spinner startAnimating];
    [spinner release];
}

这篇关于如何在加载UITableViewCell时设置UIActivityIndi​​catorView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 10:03