Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the real device's orientation?

All,
When i locked the screen orientation,i want use [[UIDevice currentDevice] orientation] to get screen's orientation ,but it always return UIDeviceOrientationPortrait, so, question is how can i get the real Device's orientation.
thank you very much.

like image 980
Yue Zhang Avatar asked Jan 17 '26 02:01

Yue Zhang


1 Answers

Make sure you're enabling orientation notifications via:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

If that still doesn't work, you can also use the status bar to figure out the current orientation (if your UI is rotating) via:

[[UIApplication sharedApplication] statusBarOrientation];

like image 151
thomashw Avatar answered Jan 19 '26 16:01

thomashw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!