【发布时间】:2016-02-19 10:08:06
【问题描述】:
我设置了一个函数来确定设备的界面方向如下。
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 设备上。 我不知道如何让它确定正确的方向。
【问题讨论】:
-
UIDeviceOrientation 怎么样?
-
我也尝试过 UIDeviceOrientation,但 iOS7 和 iOS 8 iPhone 都打印了“UIDeviceOrientationUnknown”,并且该应用在启动时仍以横向显示。
-
愚蠢的问题你开始收听方向变化通知了吗?
-
你试过检查状态栏
[[UIApplication sharedApplication] statusBarOrientation]的方向了吗? -
我试过了....也没有用。
标签: ios objective-c landscape uiinterfaceorientation portrait