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

问题描述:

我正在实施通用应用程序。在我的应用程序中,我需要对iPhone的屏幕进行自动旋转,而不是iPhone。但我该怎么做?你能帮我吗我试着用下面的代码,但它不工作。如何禁用iPhone应用程序的自动旋转?

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

最后,我通过对plist文件中的属性进行了更改。

在努力设置UIViewController的shouldAutorotatesupportedInterfaceOrientation方法后,在iOS6中没有成功,我发现最有效的方法是将其设置在应用程序委托中。

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

但是返回UIInterfaceOrientationMaskPortraitUpsideDown崩溃了我的应用程序。我不知道我做错了什么!