如何让应用程序保持纵向模式

时间:2012-06-03 19:51:26

标签: ios xcode

当我运行它时,我似乎无法将我的应用程序保持在纵向模式,我将支持的设备方向设置为仅纵向并且它仍然旋转,所有帮助将不胜感激,谢谢!

2 个答案:

答案 0 :(得分:3)

在所有视图控制器中写下

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

同样在project-info.plist

更改密钥的值

<key>UISupportedInterfaceOrientationss</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>

<key>UISupportedInterfaceOrientationss</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
</array>

答案 1 :(得分:0)

将此内容写入所有viewcontrollers:

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