iOS 8.1自动旋转 [英] iOS 8.1 auto rotation

查看:68
本文介绍了iOS 8.1自动旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我检查了所需的所有方向类型! 在iOS 7.1上可以正常使用,但在iOS 8.1上无法正常使用.在iOS 8.1中,当我以纵向或横向模式打开应用程序时,它可以正常工作,但是在使用中,我旋转设备时,只有状态栏会更改旋转! 我怎样才能解决这个问题?

In my project I check all the types of orientations I need! This works fine on iOS 7.1 but it doesn't work properly for iOS 8.1. In iOS 8.1, when I open the app in portrait or landscape mode it works fine but when in middle of use I rotate my device only the status bar changes the rotation! How can I fix this?

推荐答案

我很多天都遇到同样的问题,并从 ChrisJP的链接.

I had same issue many days and got answer from ChrisJP's link.

appdelegate.m文件,在应用程序didFinishLaunchingWithOptions中注释以下代码.

appdelegate.m file, comment the following code in application didFinishLaunchingWithOptions.

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

以下是链接中的文字(以防过期或人们不想登录开发者论坛):

Here is the text from the link (in case it expires or people don't want to log in to the developer forums):

我设法解决了这个问题!

"I've managed to fix this!

我想你们也都在使用情节提要吗?如果是这样,从不使用情节提要板开始,您的应用程序委托中可能已经有一些旧的遗留代码,事实证明,使用情节提要板时不再需要此代码,但是直到8.1无效为止.

I assume you guys are all using storyboards too? If so, you've probably got some old leftover code in your app delegate from when you weren't using storyboards, turns out this was no longer needed when storyboards are used, but until 8.1 has had no effect.

  1. 确保将情节提要中的导航控制器(或您使用的任何控制器)设置为初始视图控制器"

  1. Make sure your navigation controller (or whatever you're using) is set as "Initial View Controller" in your storyboard

在您的appdelegate.m文件中,删除出现在应用程序didFinishLaunchingWithOptions中的对UIWindow和rootViewController的任何引用.对于我来说,我仍然有以下两行内容,在删除之后,它们解决了我的问题:

In your appdelegate.m file, remove any references to UIWindow and rootViewController that appear in application didFinishLaunchingWithOptions. For me, I still had the following two lines, which after removing, fixed my issues:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [self.window makeKeyAndVisible];

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [self.window makeKeyAndVisible];

我也正在设置self.window.rootViewController.除非您出于某种原因要覆盖它,否则也不需要设置它.

and also I was setting self.window.rootViewController. This also does not need to be set unless you're overriding it for some reason.

这就是为我解决的问题,希望对你们也有帮助."

That's what fixed it for me, hopefully it does for you guys too."

这篇关于iOS 8.1自动旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆