How to check the orientation of the device?

I am looking for a quick way to find out if the device with the home button is held right or left. Is there a function for this?

+3
source share
1 answer

Look at the documentation UIDevice. There is an orientation property. Sort of:

UIDeviceOrientation d = [[UIDevice currentDevice] orientation];

The values dyou are looking for are as follows:

UIDeviceOrientationLandscapeLeft - The device is in landscape mode, while the device is held in a vertical position, and the home button is on the right side.

UIDeviceOrientationLandscapeRight - The device is in landscape mode, while the device is held upright and the "Home" button is on the left side.

+8
source

Source: https://habr.com/ru/post/1774378/


All Articles