I'm using storyboard and Xcode 6 to design app views but I'm facing this issue: I want to assign different positions of subviews for portrait and landscape modes. For example:
Since now I've achieved this programmatically with willRotateToInterfaceOrientation and status bar to get ipad orientation.
With Xcode 6, iPhone layouts for portrait and landscape are different, but are the same for iPad (regular, regular). It's is possible to achieved those positions with constraints?
Press the plus "+" beside the Constant of a constraint and add variations for different screens:
I know this is an old post but, just for info.I tried the below steps and it is working as expected.
Step1. Select View controller, Select any from size class control. And add the Views in this mode. Any Mode Step2. Change the mode to portrait all iPhones from size class control, add constraints for the view for portrait mode. Potrait mode Step3. Similarly Change the mode to landscape all iPhones, add constraints for the view for landscape mode.
Please note: The constraints are independent now for portrait and landscape
Yes, you can do this with constraints.
First, you need to create constraints to the superview, not to the nearest view. Neighboring views will be changing positions, so we DO NOT want the constraints to be relative to the other views. See the screenshot below for an example of how to set the constraints.
Next, link the constraints you'll be modifying to IBOutlets so we can modify them programmatically. For your example, these would be the constraints:
Finally, update the constraint constants based on UIInterfaceOrientation. Again, using your example, the code looks something like this: