从UITableView1导航到UITableView2时,应显示活动指示器 [英] Activity indicator should be displayed when navigating from UITableView1 to UITableView2

查看:95
本文介绍了从UITableView1导航到UITableView2时,应显示活动指示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在从一个UITableView1导航到另一个UITableView2时显示一个活动指示器,并在表完全加载时停止。

I want to display an activity indicator when navigating form one UITableView1 to another UITableView2 and stop when the table is completely loaded.

我正在使用XML解析来获取UITableView2的单元格内容。

I am using XML parsing to get the cell content of UITableView2.

推荐答案

以下代码可以帮助您...

Following code may help you...

在UITableView2的.h文件中:

in .h file of UITableView2:

声明变量

UIActivityIndicatorView *progressInd;

创建属性

@property (nonatomic, retain) UIActivityIndicatorView *progressInd;

并声明方法

- (UIActivityIndicatorView *)progressInd;

在UITableView2的.m文件中:

in .m file of UITableView2:

@synthesize progressInd;

定义此方法(调整x,y,宽度,宽度位置)

define this method (adjust x,y,width,width position)

- (UIActivityIndicatorView *)progressInd {
if (progressInd == nil)
{
    CGRect frame = CGRectMake(self.view.frame.size.width/2-15, self.view.frame.size.height/2-15, 30, 30);
    progressInd = [[UIActivityIndicatorView alloc] initWithFrame:frame];
    [progressInd startAnimating];
    progressInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
    [progressInd sizeToFit];
    progressInd.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
                                    UIViewAutoresizingFlexibleRightMargin |
                                    UIViewAutoresizingFlexibleTopMargin |
                                    UIViewAutoresizingFlexibleBottomMargin);

    progressInd.tag = 1;    // tag this view for later so we can remove it from recycled table cells
}
return progressInd;
}

in - (void)viewDidLoad 解析开始的方法

in - (void)viewDidLoad method where your parsing starts

[self.view addSubview:self.progressInd];

使用以下行解析结束

[self.progressInd removeFromSuperview];

这篇关于从UITableView1导航到UITableView2时,应显示活动指示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆