I am confused by the frame of self.view
within a ViewController I have made the root ViewController of a UINavigationViewController. Lets say I add a red square UIView to self.view
(where self.view is the embedded ViewController's view property). This red view is mostly occluded by the navigation bar. In other words, why doesn't self.view
's frame's origin.Y = HeightOfNav bar? Instead it is 0.
I have read documentation that states a view added to the navigation controller resizes to take the nav bar's height into account, however, all my testing has shown this isn't the case. Not at any point in the view lifecycle does my view correct its origin to be visible. Perhaps I am setting up this viewcontroller/navigationController incorrectly such that the appropriate view-resizing does not take place but you can read the subsequent code to see if that is the case.
Here is the simple code where I generate these view controllers in appdelegate:
UIViewController * a = [[ViewController alloc] init];
UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:a];
self.window.rootViewController = nav;
Logging out self.view
's frame in a
's viewDidLoad
, viewWillAppear
, viewDidAppear
, etc.. shows { 0, 0, screenWidth, screenHeight } (where screen* is the current simulator). So, 0,0 is behind a navBar and this is not the behavior I would expect.
Again, my expectation was that self.view
would now have a frame whose origin starts after the NavigationBar at the top of any view inside a UINavigationController.