views:

216

answers:

1

I am trying to figure out what orientation the iphone has in the simulator and instead of giving it to me using the UIDevice orientation property I just get UIDeviceOrientationUnknown.

Does this property not work in the simulator? What could be the possible reason for this happening?

I am using opengl es

+1  A: 

first of all, from the documentation about orientation property of UIDevice instance

The value of this property always returns 0 unless orientation notifications have been enabled by calling beginGeneratingDeviceOrientationNotifications.

and yes, it will work only on the real device. but you can use, for example, this accelerometer simulator.

Morion
Sorry but no, it does not work only on the real device. I just loggued a landscape device orientation on the simulator and then a portrait one. Maybe it was not the case with previous SDK versions... (I'm on 3.1.3)I guess we can use -[UIApplication statusBarOrientation] to determine the current interface orientation (except if we manually change the status bar orientation). And I'm not sure if this will work with a hidden status bar.
Unfalkster