views:

40

answers:

1

I'm having an issue where some of my views look incorrect on App load until you rotate the device, and some where they look correct after load but incorrect after rotating.

I have a window that loads with View A and after a button press, detachs View A from the window (RemoveFromSuperView) and loads View B and adds it to the window.

View A - has white space on the bottom the height of the status bar, which is fixed on rotation of the device.

View B - looks correct on load, but has part of bottom chopped off after device rotation.

What would cause this strange behavior?

If I view my XIB files from Interface Builder through File->Simulate Interface, they work fine. But they don't work from my application, same thing happens on actual device too.

PS - I don't think I have any custom code that should cause this, I just created Views A and B in IB and hooked them up to subclassed controllers so I could override ShouldAutorotateToInterfaceOrientation.

A: 

It was because my view controllers are being created from code.

I switched to my controllers being created from XIB files, apparently they are resized correctly and take the status bar into account when doing this.

I also had to verify "Resize View From NIB" was checked in Interface Builder with the appropriate child NIB name present. You can skip this step if your controller isn't laid out in a second XIB file.

Jonathan.Peppers
Another situation I found this to occur is when a TabBarController's view is a sub-view of another controller. To remedy the problem, I set the parent controller's View property to the TabBarController's View. This seems hackish for what I was trying to do, but I could not find another way to fix it.
Jonathan.Peppers