SOLVED: Check below for the solution to my problem.
Hey SO,
I
Set center in viewDidLayoutSubviews.
- (void) viewDidLayoutSubviews {
self.myActivityIndicator.center = self.view.center;
}
I'm not sure what is exactly going on, but maybe your UIScrollView is taller than the screen? You could try printing the size of your UIView to determine if is in the screen bounds. Perhaps the UIActivityIndicator is on the center of the UIView (not the center of the screen).
use spinner.center = self.scrollView.center; instead
try this
spinner.center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds));
Two problems:
First, self.view.center is the center of the current view's frame on it's parent's frame. If you want the center of the current view, you want CGPointMake(self.view.frame.size.width / 2.0, self.view.frame.size.height / 2.0);
Second, your current view does not include the navigationbar, so you're centering it on the space of the screen below the nav bar. That will also make it look lower.
SWIFT
I was having the same issue because of a nav bar and a tab bar. To fix, place the following code in your loadView() or wherever you call your activity indicator to begin animating:
let navigationBarHeight = self.navigationController?.navigationBar.frame.height
let tabBarHeight = super.tabBarController!.tabBar.frame.height
YourActivityIndicator.center = CGPointMake(self.view.frame.size.width / 2.0, (self.view.frame.size.height - navigationBarHeight! - tabBarHeight) / 2.0)