Centralization Activity Indicator for UITableView

I created UITableViewControllerin my storyboard and then dragged the activity indicator view onto the controller (along with creating an output for it), from which I start and stop the animation before and after loading some json content.

I see that the ajax spinner is working fine, but it visually appears under my navigation area / name, and when I try to center it, it seems centered in width, appears at the very top near the status area ...

I tried to do the following, trying to focus it ... Here's a quick look at mine viewDidLoad:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.listLoader.center = CGPointMake( [UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2);
    UITableView *appDelegate = (UITableView *)[[UIApplication sharedApplication] delegate];
    [appDelegate.window addSubview:self.listLoader];

    self.operationQueue = [NSOperationQueue new];
    NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(getPosts) object:nil];
    [self.operationQueue addOperation:operation];
}

, startAnimating stopAnimating getPosts . , , , . , ...

self.listLoader.center = CGPointMake( [UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2);
UITableView *appDelegate = (UITableView *)[[UIApplication sharedApplication] delegate];
[appDelegate.window addSubview:self.listLoader];

...

? , , , , ....

+4
3

, UITableViewController tableView, tableViews - scrollviews, . tableviews , , . "" .

- ViewController . THEN viewcontroller .

tableviewcontroller, :

UITableView, Apple

+3

UIView ViewController , , UITableView .

UITableView UIView. .

UIActivityIndicator in. UIView, UITableView ( ). x/y, , ( ).

+1

The best I've come across:

// Center 
CGFloat x = UIScreen.mainScreen.applicationFrame.size.width/2;
CGFloat y = UIScreen.mainScreen.applicationFrame.size.height/2;
// Offset. If tableView has been scrolled
CGFloat yOffset = self.tableView.contentOffset.y;
self.activityView.frame = CGRectMake(x, y + yOffset, 0, 0);

as defined in the following: IOS: ActivityIndicator UITableView... ?

, , , .

It is simple, without hacking.

+1
source

All Articles