Ios 如何保持应用程序处于纵向模式

Ios 如何保持应用程序处于纵向模式,ios,xcode,Ios,Xcode,当我运行应用程序时,我似乎无法将其保持在纵向模式,我将支持的设备方向设置为仅纵向,并且它仍在旋转,所有帮助将不胜感激,谢谢 将其写入所有视图控制器中 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return NO; } 也在project-info.plist中 更改键的值 <key>UISupportedInterfaceOrie

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

将其写入所有视图控制器中

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return NO;
}
也在project-info.plist中

更改键的值

<key>UISupportedInterfaceOrientationss</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>
UI支持的界面方向
UIInterfaceOrientationPortrait
UIInterface方向和左视图
UIInterfaceOrientationAndscapeRight

UI支持的界面方向
UIInterfaceOrientationPortrait

将此内容写入您的所有ViewController:

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

他说的是对的。要进一步展开,有时在创建某些文件后设置设备方向时,旧文件将不会自动更正。您必须自动执行此操作。进行这些更改后的所有新文件都应该是正确的。这将为您提供一个NSLog条目,告诉您至少支持一个方向,而不是仅返回NO use@Maxim Mikheev对
shouldAutorotateToInterfaceOrientation
方法的回答。我仍然可以旋转到横向模式。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}