Apple’s docs say:
Note: Because the amount of space available for the custom view can vary
(depending on the size of the other navigation views), your custom view’s
autoresizingMask property should be set to have a flexible width and height.
Before displaying your view, the navigation controller automatically
positions and sizes it to fit the available space.
That’s great, except … I need to know the size UINavController will use BEFORE the view is added to the frame, because the content I’ll be displaying is different depending on the size.
This is inside the “loadView” method of a UIViewController that’s being added to the UINavigationController.
Well, technically you shouldn’t be sizing your subviews in the
loadViewmethod. I don’t use nibs, and in almost all of my view controllers theloadViewis really small:self.view = [[UIView alloc] init];. Then, inviewDidLoadI add all my subviews toself.view. Finally, I do all of my resizing inviewWillAppear, because at that pointself.viewwill be the appropriate size.If you must size views in the
loadViewmethod, you’ll have to calculate out the dimensions manually…i.e: find out the orientation of the device (self.interfaceOrientation) determine the screen size, subtract out whatever other elements you think are on screen (like a Navigation bar, etc). But this method is not recommended.