Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
438 views
in Technique[技术] by (71.8m points)

iphone - Activity indicator should be displayed when navigating from UITableView1 to UITableView2

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Following code may help you...

in .h file of UITableView2:

declare variable

UIActivityIndicatorView *progressInd;

create property

@property (nonatomic, retain) UIActivityIndicatorView *progressInd;

and declare method

- (UIActivityIndicatorView *)progressInd;

in .m file of UITableView2:

@synthesize progressInd;

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 method where your parsing starts

[self.view addSubview:self.progressInd];

use following line where your parsing ends

[self.progressInd removeFromSuperview];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...