views:

297

answers:

2

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?

+1  A: 

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.

CaseyB
+1  A: 

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..

bitcruncher