1
votes

I have been checking out some posts on bounds vs frames but still a bit confused.

I have the following hierarchy: UITabBarController > UINavigationController > UIViewController

When I tried the following NSLog

NSLog(@"%f %f %f",[[[self tabBarController] view] bounds].size.height, [[[self navigationController] view] bounds].size.height, [[self view] bounds].size.height);

I get the following Output:

480.000000 431.000000 460.000000

I understand the 20 difference accounts for the status bar height, but I don't understand why the UIViewController's bound excludes the status bar height, but that for UINavigationController and UITabBarController include...

REFINING MY QUESTION

1) Why does the top tabBarController has a height of 480.0 (why doesn't it exclude the status bar height of 20pt???). Ok, let me assume height will always NOT exclude the status bar height and move on for now

2) The UINavigationController has a height of 431.0 (ok, a reasonable guess is that it is 480-49, where 49 is the height of the tab bar). But why does it selectively exclude the height of the tab bar but NOT the height of the status bar??? Apple's View Programming Guide doesn't not seem to explain that... but let's move on...

3) Why does my UIViewController has a height of 460?!

(3a) why does it exclude the 20pt height of the status bar unlike UITabBarController and UINavigationController???

(3b) AND MORE importantly, why does it NOT exclude the height of the navigation bar (i.e. why shouldn't it be 431-44 = 387?!)

(3c) why does my UIViewController which is INSIDE my UINavigationController has a LONGER height than the UINavigationController???

1
Read the Apple Guide on UIViewControllers - it completely explains how these views fit together.David H
@DavidH - sorry for being ignorant. I checked out Apple's documentation on UIViewController class and View Controller Programming Guide for iOS and it hardly ever mention bounds at allminovsky
Sorry, its the 'View Programming Guide'.David H
@DavidH - Thanks David, I read through the guide, but it does not answer my question (i made a mistake previously pls see the edit which fixed that and I have expanded my question, and please kindly let me know where have the guide answered my question?).minovsky

1 Answers

0
votes

Kinda figured it out... I was putting the NSLog in viewDidLoad, if I move them to viewDidAppear, the height for the UIViewController was 367 (=480-20-44-49) as expected and its origin is (0, 64), which accounts for the 20pt of status bar and 44pt of the navbar

and for the UINavigationController, even though it's origin.y is at 0 and it has a height of 480.0, when I printed the frame for its navigationBar directly the navbar has an origin.y of 20, so basically the UINavigationController's frame is still at the full screen but the top 20pt (where the status bar is) is empty