开发者

MonoTouch app - Layout Problems with Rotation

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜