我正在开发一个 iPhone 应用程序。现在我所有的 View Controller 都旋转到纵向、横向左侧和横向右侧(开箱即用的 iPhone 应用程序的默认行为)。我想要的是我的应用程序设置,应用程序范围,包括对所有界面方向的支持。我该如何做到这一点?我在项目级别选择了所有界面方向,这没有任何区别。这是一张照片:
现在,当我在 iPhone 上测试我的应用程序时,它拒绝旋转到 UIInterfaceOrientationPortraitUpsideDown
.为什么?
好的,一旦我们弄清楚了,就会有一个后续问题......我的应用程序中有一个 View Controller ,我只想支持 UIInterfaceOrientationPortrait
和 UIInterfaceOrientationPortraitUpsideDown
我怎样才能做到这一点?我的 Controller 中有以下代码,但它不起作用:
// The following method never gets called (but wanted to
// include this to show that I've tried it).
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
// This method does get called but has no effect. The VC that this method
// belongs to rotates to all interface orientations except for
// UIInterfaceOrientationPortraitUpsideDown which is definitely
// not what I want...
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown;
}
// This method never gets called either and therefore has no effect...
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}
请注意,我的应用程序是基于 Storyboard 的(如果这有什么不同的话)。任何帮助将非常感激!谢谢。
最佳答案
按照 Landscape Mode ONLY for iPhone or iPad 中的说明进行操作并在执行此操作时添加evey界面方向,它将支持所有方向。
更改您的应用程序的Info.plist
文件:
添加 Supported interface orientations
行到您的应用程序的Info.plist
具有所有支持的界面方向的文件
将支持的界面方向添加到“支持的界面方向”。
(Targets -> YourApp -> Supported Interface Orientations -> Landscape Left & Right
)
关于ios - 如何让 iOS 7 iPhone 应用旋转到所有界面方向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20775232/