IPAD direction returns unknown value

I use this code:

UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];

Get the iPad orientation, but in When rendering with OpenGL, it returns UIDeviceOrientationUnknown. When I play a movie or show UIViews, it returns the correct value. Do you know how I can get the correct orientation? I don’t want to use an accelerometer because I want to know when the device locks its orientation.

Thank you!

In some cases, the accelerometer cannot accurately read the direction, such as when the device remains flat .You can still use the following methods to get the current orientation:

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

I use this code:

UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];

Get the iPad orientation, but return UIDeviceOrientationUnknown when using OpenGL rendering. When I play a movie or show UIViews, it returns the correct value. Do you know how I can get the correct direction? I don’t want to use an accelerometer because I want to know when the device locks its orientation.

Thank you!

In some cases, the accelerometer cannot accurately read the direction, such as when the device remains flat. You can still use the following methods to get the current direction: < p>

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

Leave a Comment

Your email address will not be published.