Activity indicator should be displayed when navigating from UITableView1 to UITableView2

杀马特。学长 韩版系。学妹 提交于 2019-11-27 17:00:15

问题


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.


回答1:


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];


来源:https://stackoverflow.com/questions/2153653/activity-indicator-should-be-displayed-when-navigating-from-uitableview1-to-uita

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!