Eas*_*y K 2 iphone ipad ios ios6
我有一个Tab栏应用程序.我正在使用XCode 4.3.3.我用iOS6的东西升级到了4.5.2.
我在shouldAutorotateToInterfaceOrientation每个视图中的代码将检查当前的设备方向并正确放置所有UI组件.
但升级到iOS 6后,此代码未执行.我已经尝试了差不多一天来解决这个问题,但没有运气.
我也试过了
UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];
Run Code Online (Sandbox Code Playgroud)
在viewLoad,viewDidLoad,viewWillAppear
如果我想在视图加载期间检查方向,并在视图加载期间将UI组件放置到适当的位置,我该怎么办?请提出你的建议.
谢谢
Nir*_*tel 11
如果你想检查哪个是当前方向,那么你只需要写下prifix.pch下面的行
#define isPortrait [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown
Run Code Online (Sandbox Code Playgroud)
然后你要检查方向,写下如下条件
if(isPortrait)
{
//portrait mode....
}
else
{
//landscape mode....
}
Run Code Online (Sandbox Code Playgroud)
让我知道它的工作与否......
快乐的编码!