SOLVED: below to solve my problem.

Hey SO
I'm having trouble centering the UIActivityIndicator ID in the view center. As you can see here, this is a little further down than it should be. I have a UIScrollView that later adds a UIImage routine. Before the UIImage loads, I have this UIActivityIndicator to show that the image is loading.
- (void)viewDidLoad
{
[super viewDidLoad];
self.scrollView.backgroundColor = [UIColor blackColor];
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.center = self.view.center;
[spinner startAnimating];
[self.view addSubview:spinner];
Any ideas on how I can get the CGPoint Center and set the UIActivityIndicator there? I am not sure why it self.view.centerdoes not work.
Thanks in advance.
EDIT: I had to consider the height of the navigation bar and tab bar. The code I had to add was:
float navigationBarHeight = [[self.navigationController navigationBar] frame].size.height;
float tabBarHeight = [[[super tabBarController] tabBar] frame].size.height;
spinner.center = CGPointMake(self.view.frame.size.width / 2.0, (self.view.frame.size.height - navigationBarHeight - tabBarHeight) / 2.0);

source
share