开发者社区> 问答> 正文

ios中如何固定单个viewController的方向?

app需要支持两个屏幕方向,其中一些controller是固定竖屏,一些是固定横屏,我试了下stackoverflow中的这种方法,http://stackoverflow.com/questions/12520030/how-to-force-a-uiviewcontroller-to-portait-orientation-in-ios-6 但还是不管用啊,还有那个shouldAutorotateToInterfaceOrientation方法出设置断点也没反应,太奇怪了

展开
收起
a123456678 2016-07-20 16:51:37 2030 0
1 条回答
写回答
取消 提交回答
  • - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
            return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
    }
    
    - (NSUInteger)supportedInterfaceOrientations
    {
    //    return UIInterfaceOrientationMaskLandscapeLeft;
        return UIInterfaceOrientationMaskLandscapeRight;
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
        return UIInterfaceOrientationLandscapeRight;
    //    return UIInterfaceOrientationPortrait;
    }
    2019-07-17 19:59:02
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
手淘iOS性能优化探索 立即下载
From Java/Android to Swift iOS 立即下载
深入剖析iOS性能优化 立即下载