views:

110

answers:

2

I am trying to create a UIView in Interface Builder that shows to the user two boxes containing some text. This UIView should support both landscape and portrait modes.

When in portrait orientation, the two boxes should be centered horizontally and be under each other. Like in the picture below: Portrait Mode

But when in landscape orientation, it should show the two boxes centered vertically and by side by side. Like in the picture below: Landscape Mode

Is this possible using only the autosizing options (or any other IB options), or do I have to relayout the view in code on orientation change events? I would prefer using only IB.

I tried locking the top and left margins of the top box and locking the bottom and right margins of the bottom box. But the problem is that for it to work I also need to shrink the two boxes as one changes from portrait to landscape, because otherwise they would overlap.

+1  A: 

I would make two views and use the same model. I find this greatly simplifies my code. However if you insist on one view, just lay them out on rotation.

Steve Riggins
A: 

i did something like this previously..

what i did was done by codes.. on willRotateToInterfaceOrientation:duration: method call, i will replot the center points of the view..

it works for me :)

Yit Ming