How to Set UI Orientation Without Code in iPhone
In this article I will explain how to set the iPhone screen orientation without any code.
In this article I will try to teach you how to set the screen orientation of an iPhone. In other words, when we make an application in Portrait mode and test in the device, it's content position changes when we move the device into Landscape mode. To understand that use the following procedure.
Open ViewController.Xib and click on the top side of the Property window of Xcode. Select file inspector and Unmark "Use Autolayout".
Initially, mark "Use Autolayout":
Here unmark "Use Autolayout":
Now click on the Size inspector at the top side of the Property window:
Here we set Position (Autosizeing) of all outlets one by one.
First I select Username Label and set it's size according to Coordinate (x, y). Here I fix it's right side:
Now I select the Text field of the username and fix it's middle portion:
Now select the Login button and fix it's frame and bounds according to coordinates:
Check the output in the Simulator .
Output 1 (Portrait mode) in iPhone:
Output 2 (Landscape Mode) before the set Orientation in the iPhone:
Output 3 (Landscape Mode) after the set Orientation in the iPhone: