我有一个标签栏应用程序。我使用的是 XCode 4.3.3。我已经升级到 4.5.2 与 iOS6 的东西。
我在每个 View 的 shouldAutorotateToInterfaceOrientation
中的代码将检查当前设备方向并正确放置所有 UI 组件。
但是升级到iOS 6后,这段代码不执行了。我已经尝试了将近一天来解决这个问题,但没有运气。
我也试过
UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];
在viewLoad
、viewDidLoad
、viewWillAppear
如果我想在 View 加载期间检查方向并在 View 加载期间将 UI 组件放置到适当的位置,我应该怎么做。请提出您的建议。
谢谢
最佳答案
如果你想检查哪个是当前方向,那么你只需在 prifix.pch 的下面写
#define isPortrait [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown
然后在你要检查方向的地方写条件如下
if(isPortrait)
{
//portrait mode....
}
else
{
//landscape mode....
}
让我知道它是否有效...
编码愉快!
关于iphone - View 加载期间 iOS 6 中的设备方向处理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14189828/