I have a View Controller that is portrait-only. When I rotate the phone I want to display a second View Controller that is landscape-only. How can I get this working on iOS 8?
Under iOS 7, everything works fine: I listen for UIDeviceOrientationDidChangeNotification
, then present the landscape view controller over the first. I use a custom animation controller that replicates the native rotation animation. I animate the transform
property to rotate the view into place, then call setStatusBarOrientation:animated:
to update the system.
On iOS8 the visuals work, but after rotation touch handling is broken on the right half of the screen. In fact, any touches received anywhere in the pink area are mapped to x = 414
. So the touches register, but are assigned an incorrect x
coordinate.
This appears to be the same problem described here where the guy describes receiving touches only on a small strip right around the edge of the portrait window frame. This also appears to be related to this problem.
The problem seems to be that the underlying UIWindow is not getting rotated by the call to setStatusBarOrientation:animated:
. Looking at it in the debugger, I see that calling this function changes the UIDevice bounds to landscape, but the UIWindow bounds stay in portrait.
According to the docs
The two principal functions of a window are to provide an area for displaying its views and to distribute events to the views.
So this touch-distributing function seems to be getting mangled.
Can anyone suggest a way to get this working in iOS 8? Regardless of the new size classes and UITraitCollection stuff, I should still be able to apply a rotation transform to a view and not have that break touch handling. Right?
Alternatively, is there an easier way to present a view controller into landscape without having to implement the animation manually?