Is there a special method to get iPhones orientation? I don't need it in degrees or radians, I want it to return an UIInterfaceOrientation object. I just need it for an if-else construction like
if(currentOrientation==UIInterfaceOrientationPortrait ||currentOrientation==UIInterfaceOrientationPortraitUpsideDown) { //Code } if (currentOrientation==UIInterfaceOrientationLandscapeRight ||currentOrientation==UIInterfaceOrientationLandscapeLeft ) { //Code }
Thanks in advance!
To adjust the screen rotation settings: Swipe down from the top of the screen to open the Quick settings panel. Look for the screen orientation icon. Depending on your settings, you may need to look for the Portrait, Landscape, or Auto Rotate icon.
This is most likely what you want:
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
You can then use system macros like:
if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) { }
If you want the device orientation use:
UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation];
This includes enumerations like UIDeviceOrientationFaceUp
and UIDeviceOrientationFaceDown
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With