开发者

How do I check the orientation of the device?

开发者 https://www.devze.com 2023-01-25 04:22 出处:网络
I\'m loo开发者_运维问答king for a quick way to tell if the device is being held with the home button to the right or to the left.Is there a function to do so?Look at the UIDevice documentation.There i

I'm loo开发者_运维问答king for a quick way to tell if the device is being held with the home button to the right or to the left. Is there a function to do so?


Look at the UIDevice documentation. There is an orientation property available. Something like:

UIDeviceOrientation d = [[UIDevice currentDevice] orientation];

The values of d you are looking for are:

UIDeviceOrientationLandscapeLeft - The device is in landscape mode, with the device held upright and the home button on the right side.

UIDeviceOrientationLandscapeRight - The device is in landscape mode, with the device held upright and the home button on the left side.

0

精彩评论

暂无评论...
验证码 换一张
取 消