views:

647

answers:

2

My application has a tab bar, and in one tab I have a navigation controller.

I want to find the position of the center of the view that appears between the navigation bar and tab bar, so that I can display a UIActivityIndicatorView right in the middle of the view when stuff happens.

However, I'm getting different values of self.view.bounds.size depending on where I am in the navigation hierarchy. At the top level, it tells me 320x460 but it's 320x367 in deeper levels.

320x367 is the size I'm expecting (and confirmed in IB by the size inspector). So why am I seeing different on the top level only?

A: 

Tried self.view.frame instead of bounds?

Nick Bedford
self.view.frame gives the same dimensions but a different origin - (0,20) instead of (0,0). Still says the table view is 460px high, when it's clearly not.
Chris Newman
A: 

Answering own question by approaching the original problem a different way.

I was trying to create a UIActivityIndicator using initWithFrame, passing it coordinates for the center of the current view, calculated from its bounds.

However, this is unnecessarily complicated. I can simply set

activityIndicator.center = self.view.center;

to align the activity indicator right in the middle of the main view.

Chris Newman