无法在iOS9中强制应用仅限纵向

我需要我的应用程序才支持纵向方向。 但升级到iOS9后,方向设置似乎没有任何效果。 我已经完成了这个答案,这是我的应用程序设置:

方向设置

但仍然应用程序进入景观。 我究竟做错了什么?

请查看Info.plist以获取“支持的接口方向”。 必须根据您的要求显示Portrait。 有时它不会更新为常规选项卡中的项目设置。 如果您在此处找到横向方向,请将其移除。

UISupportedInterfaceOrientations  UIInterfaceOrientationPortrait  

在此处输入图像描述

iOS9中存在某种错误。 它完全忽略了plist文件方向设置。 所以我不得不将这个代码添加到我的每个UIViewControllers中以获得纵向方向。

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations if (interfaceOrientation == UIInterfaceOrientationPortrait) { return YES; } else { return NO; } } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; } #if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000 - (NSUInteger)supportedInterfaceOrientations #else - (UIInterfaceOrientationMask)supportedInterfaceOrientations #endif { return UIInterfaceOrientationMaskPortrait; } 

看起来我发现了问题。 当我查看info.plist的来源时,这就是我发现的:

 UISupportedInterfaceOrientations  UIInterfaceOrientationPortrait  UISupportedInterfaceOrientations~ipad  UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight  

不知道UISupportedInterfaceOrientations~ipad键是如何形成的。 在作为属性列表查看时最初没有显示,但在打开后显示在属性列表中并保存。

现在似乎现在可以在常规选项卡中设置它。 感谢SamB和technerd让我走上了正确的道路。

PS:我不确定这是一个错误还是预期的行为,所以我欢迎任何有关此问题的见解。