Question

So today I implement landscape mode for my app. It is an opengl es application. I rotated it 90 degrees. The first thing I notice is that the touches no longer work. The reason being is that the call to locationInView is still giving the coordinates as though the application is in portrait mode.

How do people typically deal with this? Do I have to write my own version of locationInView to take into account the orientation of the phone? Or is there a better way?

Was it helpful?

Solution

That's default behavior. Whether the iPhone is in portrait or landscape the screen coordinates don't change, so you'll need to adjust for that in your app.

OTHER TIPS

Basically two approaches, each with their own drawbacks/assets.

  1. You could attach your GLview to a viewcontroller and let it handle rotation events and translating window coordinates into "view" coordinates. This is the easiest method, but your drawing performance could be compromised.

  2. Manage the rotation yourself. You'll need to add your own methods for dealing with the rotations, driven by the UIDeviceOrientationDidChangeNotification notification. This method should include the GL commands to rotate the matrix, translate touches, etc..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top