Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS8 touch position is limited in Landscape, as if window is Portrait on one side?

I'm having a bizarre problem here with iOS8. I've been googling and bashing my head against a wall for a couple of days with no luck. I'm not exactly sure how to even explain it, but here goes...

Apps have been running fine under iOS7, but now compiling using xCode 6/iOS8 I'm having a few strange orientation problems. I'm not using a xib file, but instead creating a window and view programatically. I'm running OpenGL in the view, and then handling everything else inside OpenGL. So, I'm collecting touches and passing them to my GL routines. All has been fine forever, til now.

Now with iOS8 it seems as if the "touch window" is rotating itself so that touches in Landscape are limited to one side of the screen, as if the display window is Landscape, but the touches are all within a Portrait window that is set to on one side of the screen.

What seems bizarre is that touches come through to the view all over the screen as normal, but the Y value stops at 320 and goes no further. The X acts normally. If I turn the device to Portrait (the view controller does not auto rotate), it all works, but in Landscape it switches to this strange behaviour.

I've tried all I can think of without any changes, and am not sure where to begin to work out why this could be happening. Any advice would be greatly appreciated.

like image 460
Rob Avatar asked Sep 21 '14 20:09

Rob


2 Answers

On iOS8, UIScreen is now interface oriented. In some (or should I say all of) libraries before iOS8, some checks were done to adjust that lack and swap width and height when the application was in landscape.

You should look at some code that makes some rotation and remove it.

-[UIScreen bounds],
-[UIScreen applicationFrame],
Status bar frame and
Keyboard frame are now interface-oriented.
(cf. WWDC2014 video - view controller advancements in iOS8 @ 50:41)

like image 57
Crazyrems Avatar answered Oct 12 '22 23:10

Crazyrems


In our case.
Force to rotate with view's transform caused that problem.
We removed that code, rotate with

+ (void)attemptRotationToDeviceOrientation 

and problem solved.

We called that method at our forceRotate method.

-(void)forceRotateLandscape {
    ...
    UIViewController *vc = [UIViewController new];
    [topVc presentViewController:vc animated:NO completion:nil];
    [topVc dismissViewControllerAnimated:NO completion:nil];

    supportedOrientations = UIInterfaceOrientationMaskLandscapeRight;
    [UIViewController attemptRotationToDeviceOrientation];
    ...
}
like image 34
toka Avatar answered Oct 13 '22 00:10

toka