I'm trying to create an application that supports portrait and landscape orientations for iOS devices with the usual horizontal size, and portrait only for the rest.
At the time of this writing, this would be: only portrait (for iPhone, except for 6 Plus / 6s Plus) and Portrait AND Landscape for iPhone 6 Plus / 6s Plus and iPad.
This is a similar behavior that native mail performs.
I tried, among other things, the following:
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return [.Portrait, .LandscapeLeft, .LandscapeRight]
}
override func shouldAutorotate() -> Bool {
return (traitCollection.horizontalSizeClass == .Regular)
}
However, shouldAutororate is obviously called before the interface rotates, so this happens before the traitCollection is updated.
So the question is how to achieve this? I am trying to accomplish this in the cleanest way, without referring explicitly to userInterfaceIdiom, screen size, etc.