1
votes

Landscape ModePortrait Mode

I came across a, what it seems like, simple auto layout task: display 3 items (all with the aspect ratio 1:1) above each other in portrait mode and next to each other in landscape mode.

I wasn't able to find constraints that fitted that layout... Is there a way to do it programmatically? How would you do it?

1

1 Answers

1
votes

Two options:
1. Enable Size Class in your Storyboard/Xib, and use a different set of constraints for wCompact|hRegular (Portrait) and wAny | hCompact (Landscape)
2. Do the constraints programatically according to the device's orientation. Usually I do it like this, override viewWillTransitionToSize:withTransitionCoordinator: in your view controller, and trigger a constraints update.