I have a pretty basic setup with a UINavigationController inside a UITabBarController. I'm wanting to programmatically layout the view of the rootViewController of that navcontroller, but when I look at self.view.frame inside viewDidLoad, I get this (in landscape, for example):
1. view frame: {{20, 0}, {748, 1024}} // looks like an odd portrait mode
Then I autorotate to Portrait, and I get this:
2. view frame: {{0, 0}, {768, 911}}
Then when I go back to Landscape, the frame is now this:
3. view frame: {{0, 0}, {1024, 655}}
And further autorotation events will flip-flop between frame values #2 & #3.
To get around the weirdness of #1, I'm currently doing this in viewDidLoad:
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
self.view.frame = CGRectMake(0, 0, 768, 911);
} else {
self.view.frame = CGRectMake(0, 0, 1024, 655);
}
I feel like I'm obviously missing something here. Why would the default frame of the view not match the frame when it autorotates back to the same orientation? Does the view frame not get set to the initial orientation? Very confused...
I should mention that none of the above, including my kludgy hack, changes anything visually. The reason I have the hack is so that when I layout my subviews into this view, they'll be based off of where I expect them to be, which is the top left corner just under the navigation bar.
What am I doing wrong?
UPDATE: turning off all the autosizing stuff on the view changes result #1 to be:
view frame: {{0, 0}, {748, 1024}}
That seems a tiny bit closer, but still not matching #3.
Question&Answers:
os