iOS 8 - 以横向模式启动应用程序 [英] iOS 8 - Launching the application in Landscape mode

查看:107
本文介绍了iOS 8 - 以横向模式启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iPad应用程序支持所有方向,并且在iOS 7中也运行良好。

My iPad application supports all the orientations and it worked fine in iOS 7 as well.

但是在 iOS 8 中,以横向模式启动应用程序使我的登录视图在纵向框架内绘制了横向视图。

However in iOS 8, launching the application in Landscape mode made my login view draw the landscape view within a portrait frame.

在做了一些分析之后,我发现在 Landscape 中启动时,应用程序窗口没有采用正确的方向。之后进行旋转会更正UI,因为它从该点开始采用正确的方向。

After doing some analysis I found out that the application window does not take the correct orientation while launching in Landscape. Doing a rotation after that corrects the UI since it takes the correct orientation from that point onwards.

有人能引导我完成这项工作吗?在此先感谢。

Would someone be able to guide me through this? Thanks in advance.

推荐答案

问题似乎是设置窗口时的调用顺序。在分配 rootViewController 之前,需要调用 makeKeyAndVisible 。以下工作:

The issue seems to be the order of calls when you set up the window. You need to call makeKeyAndVisible before you assign the rootViewController. The following works:

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

但如果您将订单更改为:

But if you change the order to:

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

您会遇到您遇到的行为。

You get the behavior you are experiencing.

这篇关于iOS 8 - 以横向模式启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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