UIDeviceOrientation 是机器硬件的当前旋转方向 这个你只能取值 不能设置
UIInterfaceOrientation 是你程序界面的当前旋转方向 这个可以设置
UIDeviceOrientation oriention = [UIDevice currentDevice].orientation;
UIInterfaceOrientation interfaceOriention = (UIInterfaceOrientation)oriention;
switch (interfaceOriention) {
case UIInterfaceOrientationUnknown:
NSLog(@"位置方向");
break;
case UIInterfaceOrientationPortrait:
NSLog(@"第0个旋转方向---电池栏在上");
[self shrinkScreenButtonClick];
break;
case UIInterfaceOrientationPortraitUpsideDown:
NSLog(@"第3个旋转方向---电池栏在下");
[self shrinkScreenButtonClick];
break;
case UIInterfaceOrientationLandscapeLeft:
[self fullScreenButtonClickRight];
NSLog(@"第2个旋转方向---电池栏在右");
break;
case UIInterfaceOrientationLandscapeRight:
[self fullScreenButtonClick];
NSLog(@"第1个旋转方向---电池栏在左");
break;
default:
break;
}
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
- {

这篇博客介绍了如何在iOS中判断设备的旋转方向,包括UIDeviceOrientation和UIInterfaceOrientation的区别,以及如何根据设备方向调整用户界面。通过示例代码展示了如何监听设备旋转,并实现特定方向的屏幕适配。
最低0.47元/天 解锁文章
2343

被折叠的 条评论
为什么被折叠?



