ios 6中如何禁止横屏- (BOOL)shouldAutorotate{return NO;}把plist里面的Supported interface orientation 相关横屏的设置删掉后
- (BOOL)shouldAutorotateToInterfaceOrientation:UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
以上方法都试过了,无效

解决方案 »

  1.   

    1. 可以在项目属性(高版本的xcode)里把两个方向的横屏设置为禁止
    2. 这个方法是可以用的,如果不能用,可能是哪里出了问题- (BOOL)shouldAutorotateToInterfaceOrientation:UIInterfaceOrientation)interfaceOrientation
    {
        return UIInterfaceOrientationIsPortrait(interfaceOrientation);
    }
      

  2.   

    In ios6 禁止横屏,
    - (BOOL)shouldAutorotate
    {
    return NO;
    }
    -(NSUInteger)supportedInterfaceOrientations
    {
      return UIInterfaceOrientationMaskPortrait;
    }建议你参考 blog.csdn.net/totogogo/article/details/8002173
      

  3.   

    在AppDelegate中增加,这个方法可以禁止横屏- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window  
        {  
             return UIInterfaceOrientationMaskPortrait;  
        }