景观应用程序 Xcode 5 / iOS 7

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18857964/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:48:46  来源:igfitidea点击:

Landscape Apps Xcode 5 / iOS 7

iosobjective-cxcodelandscapeios7

提问by Teofilo Israel Vizcaino Rodrig

I have a piano app in the App Store. It works in landscape mode.

我在 App Store 中有一个钢琴应用程序。它在横向模式下工作。

enter image description here

在此处输入图片说明

Now iOS 7 appears to be ignoring the Landscape setting in IB

现在 iOS 7 似乎忽略了 IB 中的 Landscape 设置

enter image description here

在此处输入图片说明

The app works as expected in iOS 6 and below, in landscape. In iOS 7 appears in portrait. Here are settings and relevant code:

该应用程序在 iOS 6 及更低版本中按预期运行。在 iOS 7 中以纵向出现。以下是设置和相关代码:

enter image description hereenter image description here

在此处输入图片说明在此处输入图片说明

//iOS 6+
- (BOOL)shouldAutorotate
{
    return YES;
}

//iOS 6+
- (NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight);
}
//iOS 5.1.1-
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
        return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

回答by Teofilo Israel Vizcaino Rodrig

Thanks to @shawnwall comment I realised I didn't have a Root View Controller. In the past my app given support yo iOS 3.1.3 O_O:

感谢@shawnwall 评论,我意识到我没有根视图控制器。过去,我的应用程序支持 iOS 3.1.3 O_O:

[self.window addSubview:self.viewController.view];

I dropped 3.1.3 support a long time ago, so I can set up a root view controller:

我很久以前就放弃了 3.1.3 支持,所以我可以设置一个根视图控制器:

self.window.rootViewController = self.viewController;

That was the thing that caused the visual bug.

这就是导致视觉错误的原因。