Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS recommended way of handling portrait and landscape orientation interfaces
    primarykey
    data
    text
    <p>I am working on an iPad app and want to support both portait and landscape orientation.</p> <p>Currently, I am seeing three ways to handle orientation:</p> <p>1) Apple recommends using two view controllers (<a href="http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/RespondingtoDeviceOrientationChanges/RespondingtoDeviceOrientationChanges.html" rel="nofollow noreferrer">http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/RespondingtoDeviceOrientationChanges/RespondingtoDeviceOrientationChanges.html</a>)</p> <p>2) The Beginning iPhone Dev book I have uses a single xib file with multiple UIView (one for portrait, one for landscape), swapping the view in the willAnimateRotationToInterfaceOrientation() method.</p> <p>3) Others have said the "proper" way to do it was using layoutSubviews and autosizing mask.</p> <p>Before, when I build an app, I would write my entire app purely in code, including interface setup and layout. The result was I ended up with a massive and very painful to tweak interface code.</p> <p>Now after writing a number of apps in purely code, I kind of appreciate why there is Interface Builder - to help manage the interface and more so, a view controller should ideally only be for managing data and sending it to the views, not managing how the views should look.</p> <p>Using Interface Builder, it makes sense to have two separate custom UIViews, one for portrait and one for landscape but I've been told otherwise that layoutSubview is the better option.</p> <p>But if I were to use layoutSubview, that would mean I have to go back to writing and managing my interface using code, which doesn't seem right to me.</p> <p>Is using layoutSubviews() really the way to go ? </p> <p>I really don't see any benefit it has over other method. Some say layoutSubviews allow you to animate the transition to the other orientation.</p> <p>My two interface isn't a simple resize button or text width when the device rotates. I have adjacent sliders next to text fields that should be stacked vertically when rotating to landscape and other sliders that needs to be moved to the other side of the screen etc.</p> <h2>edit</h2> <p>might be a duplicate questions of:</p> <p><a href="https://stackoverflow.com/questions/12062506/handle-iphone-orientation-landscape-portrait">Handle iPhone orientation Landscape/Portrait</a></p> <p><a href="https://stackoverflow.com/questions/4253623/ipad-iphone-multiple-orientations-best-practice">iPad/iPhone multiple orientations best practice?</a></p> <p>Moderators can close if need to.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload