Iphone在通用应用程序中的固定方向 [英] Fixed orientation for Iphone in universal app

查看:97
本文介绍了Iphone在通用应用程序中的固定方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个通用应用程序,我想支持IPAD的所有方向,但是对于Iphone,我只希望UIInterfaceOrientationPortrait和UIInterfaceOrientationPortraitUpsideDown可以做到这一点

I have developed a universal app I want to support all orientation for IPAD but for Iphone I just want UIInterfaceOrientationPortrait and UIInterfaceOrientationPortraitUpsideDown only for this I have

-(BOOL)shouldAutorotate {
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
        return NO;
    }else{
        return YES;
    }
}
- (NSUInteger)supportedInterfaceOrientations{

     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
         return UIInterfaceOrientationMaskPortrait;
     }else{
        return UIInterfaceOrientationMaskAll;
     }

} 
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){

    return interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ;
     }else{
         return YES;
     }

}

但是仍然不能停止横向定向

But still is not stop the orientation in landscape

推荐答案

仅从摘要中为 iPhone 禁用除UIInterfaceOrientationPortraitUIInterfaceOrientationPortraitUpsideDown以外的所有其他方向. strong>就像下面的描述一样. 在照片中,颠倒"已禁用,请启用它.谢谢.

Simply disable all other orientations except the UIInterfaceOrientationPortrait and UIInterfaceOrientationPortraitUpsideDown one for the iPhone from the Summary like in the description below. In the pic the Upside down is disabled please enable it. Thanks.

这篇关于Iphone在通用应用程序中的固定方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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