如何为iPhone应用程序禁用自动旋转?

时间:2012-11-28 05:02:24

标签: ios6 auto-rotation

我正在实施一个通用应用程序。在我的应用程序中,我需要为iPad而不是为iPhone自动旋转屏幕。我怎样才能做到这一点?我尝试使用以下代码,但它无法正常工作。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return NO;
}

2 个答案:

答案 0 :(得分:0)

最后,我通过更改plist文件中的属性来实现它。

答案 1 :(得分:0)

在努力设置UIViewController的shouldAutorotatesupportedInterfaceOrientation方法后,在iOS6中没有成功,我发现最有效的方法是在app delegate中设置它。

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskPortrait;
}

但是,返回UIInterfaceOrientationMaskPortraitUpsideDown会导致我的应用崩溃。我不知道我做错了什么!