I want to describe an issue (and its corresponding solution) I was having with Size Classes.
For a UIViewController and iPhone-only environment, I want to have a different layout for landscape and portrait. I have the corresponding designs on Interface Builder using Size Classes. However, when running the application on the simulator, I always get the portrait layout regardless of the device orientation.
I have tried 2 different approaches:
- Creating the portrait layout for the Any-Any Size Class and the landscape one for wAny-hCompact.
- Creating the portrait layout for the wCompact-hRegular, the landscape one for wAny-hCompact and a different one for Any-Any.
In both cases, everything looks good in the Preview feature of Interface Builder for all iPhone devices and orientations but on the simulator I always see the portrait layout regardless of device orientation.
I am using Xcode 7.2 and I have tried all iPhone Simulators on both iOS 8.4 and 9.2. No warnings about autolayout constraints are seen on any of the Size Classes.