Reputation: 249
Storyboards are an awesome feature - but is there a possibility to create a lanscape and a portrait view for one controller? What is the best way to do that?
I found a lot on StackOverflow, from copying a storyboard to add subviews for each orientation. It would be great, if there is a better way to do that...
Upvotes: 0
Views: 292
Reputation: 629
Autosizing works only on simplest straighforward cases. If you have to tweak just a little bit the end result, it becomes too hard. What I do to make this much more visual is I set autosizing, then duplicate the portrait view right for the same controller in the same xib and rotate it to landscae. Then I adjust the positions. But before that I set tag properties for each control. So I create actually 2 duplicate views, 1 portrait and 1 landscape and since the tags are the same, during "willRotateTo..." or "didRotateTo.." I copy the .frame property of each control from the duplicate View that I visually adjusted in xib, and that puts the control where I wanted. I can even add animation along the way.
Upvotes: 1
Reputation: 11841
You aren't supposed to create multiple scenes for every orientation. You're supposed to use autoresizing, springs and struts, custom implementations of several rotation methods and respond to notifications.
Upvotes: 0
Reputation: 5237
You want to use autosizing of subviews for each UIViewController of your storyboard. It's the cleanest way of managing rotation.
Check: http://www.techotopia.com/index.php/IOS_5_iPhone_Rotation,_View_Resizing_and_Layout_Handling
Upvotes: 0