iOS提供了一个方法 可以很简单的判断当前屏幕旋转到什么状态
UIInterfaceOrientation sataus=[UIApplication sharedApplication].statusBarOrientation;
得到结果有集中情况 他们是按照当前 Home 键在手机的什么位置
得到结果是一个枚举类型
// Note that UIInterfaceOrientationLandscapeLeft is equal to UIDeviceOrientationLandscapeRight (and vice versa). // This is because rotating the device to the left requires rotating the content to the right. typedef NS_ENUM(NSInteger, UIInterfaceOrientation) { UIInterfaceOrientationUnknown = UIDeviceOrientationUnknown, UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait, UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight, UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft };
UIInterfaceOrientationPortrait(Home键在下方)
UIInterfaceOrientationPortraitUpsideDown(Home键在顶部)
UIInterfaceOrientationLandscapeLeft(Home键在左侧)
UIInterfaceOrientationLandscapeRight(Home键在右侧)
还有一种unknow的情况 估计就是 检测不到
好了。
苹果开发群 :414319235 欢迎加入 欢迎讨论问题
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-12 12:46:30