Activity indicator should be displayed when switching from UITableView1 to UITableView2

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

I am using XML parsing to get the contents of a cell in UITableView2.

+3
source share
1 answer

The following code may help you ...

in the .h file of UITableView2:

declare a variable

UIActivityIndicatorView *progressInd;

create property

@property (nonatomic, retain) UIActivityIndicatorView *progressInd;

and declare a method

- (UIActivityIndicatorView *)progressInd;

in the .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;
}

at - (void)viewDidLoadwhere your parsing begins

[self.view addSubview:self.progressInd];

, .

[self.progressInd removeFromSuperview];
+7

Source: https://habr.com/ru/post/1730353/


All Articles