在视图加载期间iOS 6中的设备方向处理? [英] Device orientation handling in iOS 6 during view load?

查看:78
本文介绍了在视图加载期间iOS 6中的设备方向处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标签栏应用程序。我正在使用XCode 4.3.3。我用iOS6的东西升级到了4.5.2。

I have a Tab bar application. I was using XCode 4.3.3. I have upgraded to 4.5.2 with iOS6 stuffs.

每个视图的 shouldAutorotateToInterfaceOrientation 中的代码将检查当前的设备方向并正确放置所有UI组件。

My code in the shouldAutorotateToInterfaceOrientation for each view will check the current device orientation and place all the UI components properly.

但升级到iOS 6后,此代码未执行。我已经尝试了差不多一天来解决这个问题,但没有运气。

But after upgrading to iOS 6, this code is not executing. I have tried for almost one day to fix this, but had no luck.

我也试过

UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation]; 

viewLoad viewDidLoad viewWillAppear

如果我想查看方向,我该怎么办?在视图加载期间,在视图加载期间将UI组件放置到适当的位置。请提出你的建议。

What should I do if I want to check the orientation during the view load and place the UI components to appropriate places during view load. Kindly give your suggestion.

谢谢

推荐答案

如果你想检查哪个是当前方向,然后你只需在行下面的prifix.pch写入

if you want to check which is current orientation, then you just write in prifix.pch below line

 #define isPortrait [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown

然后你要检查方向,写条件就像下面

then where you want to check orientation ,write condition like below

    if(isPortrait)
    {
       //portrait mode....
    }
    else
    {
       //landscape mode....
    }

让我知道它是否正常工作......

let me know it is working or not...

快乐编码!

这篇关于在视图加载期间iOS 6中的设备方向处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆