1

我只需要在我的应用程序中支持纵向。我该怎么做?我试过添加

<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
</array>

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

但这无济于事 - 视图无论如何都会旋转。

提前致谢!

4

4 回答 4

4

-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation应该返回一个 BOOL 这是NO你的情况。

于 2010-10-02T16:47:49.203 回答
2

这应该是:

 -(BOOL)     shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return interfaceOrientation == UIInterfaceOrientationPortrait 
           || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ;
}
于 2010-10-02T17:24:44.470 回答
1

在 XCode 5(不确定早期版本)中,如果您只想在整个应用程序中支持纵向模式,请转到 Project Settings->General->Deployment info 并取消选中 Upside Down、Orientation Left 和 Orientation Right。

这可能是现在最简单的方法了。

于 2014-02-22T09:04:55.820 回答
0

对于 iOS 6,您似乎也需要添加/覆盖此方法,

-(BOOL)shouldAutorotate {
    return NO;
}
于 2013-03-06T10:10:18.480 回答