Q: UITableView and centering the Activity Indicator view I have a UITableView that fetches it's data from Parse.com. While it's doing this I want to display an Activity Indicator above the table centered. The code I have for this is:
        UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
        indicator.center=self.view.center;
        [self.view addSubview:indicator];
        [indicator startAnimating];

However it isn't quite central:

Sorry for the huge picture! I tried adding the indicator to the table superView and it didn't make a difference. Bit of a noob with all this. Could someone give me some pointers to what I might be doing wrong please?

A: No no. You don't need any of that. All you need to do is the following:
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

Once you want to turn it off, do the following:
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];

Don't worry about adding the indicator as a subview, or its position or size. Its part of the Status bar, Apple takes care of it, you can't change its size/colour/etc... You can just turn it on and off.
Update
Oh sorry, I thought you were talking about the UIStatusBar activity indicator. In answer to your question, in order to center the UIActivityIndicatorView, just do the following:
UIActivityIndicatorView *spinner = [[UIActivityIndicatorVIew alloc] 
         initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
CGRect frame = spinner.frame;
frame.origin.x = (self.view.frame.size.width / 2 - frame.size.width / 2);
frame.origin.y = (self.view.frame.size.height / 2 - frame.size.height / 2);
spinner.frame = frame;
[view addSubview:spinner];
[spinner startAnimating];


A: You can use UITableview's Background view to show ActivityIndicator.
lazy var activityIndicatorBase : UIActivityIndicatorView = {
        let activityIndicator = UIActivityIndicatorView()
        activityIndicator.frame = CGRect(x:0.0, y:0.0, width:60.0, height:60.0);
        activityIndicator.hidesWhenStopped = true
        activityIndicator.activityIndicatorViewStyle = .gray
        activityIndicator.color = UIColor.orange
        activityIndicator.startAnimating()
        return activityIndicator
    }()

To show indicator 
self.tblMessage.backgroundView = self.activityIndicatorBase

To hide indicator
self.tblMessage.backgroundView = nil


A: Try This.! 
UIActivityIndicatorView * indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
indicator.frame = CGRectMake(65, 20, indicator.bounds.size.width, indicator.bounds.size.height);
[UIApplication sharedApplication].networkActivityIndicatorVisible = TRUE;
[self.view addSubview:indicator];
[indicator startAnimating];

