HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – 通用应用程序中的IOS 6方向问题大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在我的通用应用程序中,我需要处理 iphone和ipad的不同方向.对于ipad,我需要允许横向和iphone肖像.我首先回复了以下代码

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if(UI_user_iNTERFACE_I@L_86_3@m() == UIUserInterfaceIdio@R_288_6165@)
        return UIInterfaceOrientationIsPorTrait(interfaceOrientation);

    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

在IOS 5中工作正常但在IOS 6中,自动旋转方法根本没有被解雇.之后我改变了方法,

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationMaskPorTrait;
}

即使这种方法在IOS 6中也没有被解雇.

我的plist设置是

我需要同时处理IOS 5和IOS 6的方向[iPhone-porTrait,iPad-landscape].请指导我解决这个问题.

解决方法

你的rootviewcontroller是UINavigation控制器还是UITabbarcontroller?
如果是这样,如果在视图控制器中调用这些方法,这些方法将无法工作.

因此,在这些容器视图控制器上创建一个目标C类别并添加到您的项目中.

@implementation UINavigationController (autorotatE)


 -(NSUInteger)supportedInterfaceOrientations
 {
   //make the check for iphone/ipad here

if(IPHONE)
    {
return UIInterfaceOrientationMaskPorTrait;
    } 
else
    {
return UIInterfaceOrientationMaskLandscape;
    }

 }

 - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
 {
return UIInterfaceOrientationPorTrait;
 }

 - (BOOL)shouldAutorotate
 {
return NO;
 }

大佬总结

以上是大佬教程为你收集整理的iphone – 通用应用程序中的IOS 6方向问题全部内容,希望文章能够帮你解决iphone – 通用应用程序中的IOS 6方向问题所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。