Iphone 无法在xcode 4中将屏幕方向锁定为仅纵向?

Iphone 无法在xcode 4中将屏幕方向锁定为仅纵向?,iphone,xcode,cocoa-touch,xcode4,Iphone,Xcode,Cocoa Touch,Xcode4,在xcode 4中,我无法将屏幕方向锁定为仅纵向,即使我仅选择了纵向。如何以编程方式执行此操作 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } 此代码在新的空白项目中工作对于每个视图控制器(或仅父视图控制器),

在xcode 4中,我无法将屏幕方向锁定为仅纵向,即使我仅选择了纵向。如何以编程方式执行此操作

   - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
此代码在新的空白项目中工作

对于每个视图控制器(或仅父视图控制器),实现
-shouldAutorotateToInterfaceOrientation:
将默认方向设置为纵向,然后执行以下操作:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return NO;
}
或者,您可以执行以下操作:

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

这将允许旋转到肖像,但不会远离它。

接受的答案对我也不起作用。这确实:


在“支持文件”组中的应用程序属性文件(YOURAPPNAME Info.plist)中,有一个名为“支持的界面方向”的数组。从阵列中删除两个横向值,您的应用程序将以纵向方向锁定

请发布到目前为止的代码。它似乎与我开始项目时使用的设置保持一致。我做了一个新的空白应用程序,它的工作,但不是在我现有的应用程序!!!真烦人!