UIInterfaceOrientation无法确定iOS 7和iOS 8 iPhone上的接口方向
我设置了一个函数来确定设备的接口方向,如下所示UIInterfaceOrientation无法确定iOS 7和iOS 8 iPhone上的接口方向,ios,objective-c,landscape,uiinterfaceorientation,portrait,Ios,Objective C,Landscape,Uiinterfaceorientation,Portrait,我设置了一个函数来确定设备的接口方向,如下所示 if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) { [self layoutPortrait:self.view]; NSLog(@"UIInterfaceOrientationIsPortrait"); } else if (UIInterfaceOrientationIsLandscape(self.inte
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation))
{
[self layoutPortrait:self.view];
NSLog(@"UIInterfaceOrientationIsPortrait");
}
else if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation))
{
[self layoutLandscape:self.view];
NSLog(@"UIInterfaceOrientationIsLandscape");
}
else
{
[self layoutPortrait:self.view];
NSLog(@"Unknow Interface Orientation!");
}
我总是把我的设备放在桌子上,界面方向是纵向的。
然而,它在编译时打印“UIInterfaceOrientationIsLandscape”,并且只在iOS 7和iOS 8 iPhone上出现,但在iPad和任何iOS 9设备上都不会出现。
我不知道如何让它确定正确的方向。对于io9也是如此,试着看看这个用例是否真的需要。
大多数情况下,我认为这无关紧要。UIDeviceOrientation呢?我也尝试过UIDeviceOrientation,但iOS7和iOS 8 iPhone都印有“UIDeviceOrientationUnknown”应用程序在启动时仍然显示在横向。愚蠢的问题你开始监听方向更改通知了吗?你是否尝试过检查状态栏的方向
[[UIApplication sharedApplication]statusBarOrientation]
了?我试过了……它也不起作用。我不确定苹果是否已经存在错误,我想困难是因为我们在x和y方向都需要额外的“G”传感器,今天我想我们只有一个轴上的传感器。在修复之前,最好修改用例/UX以使其不被注意到。