简体   繁体   English

旋转行为iOS8与iOS9

[英]Rotation behaviour iOS8 vs iOS9

I have a app that is locked to portrait in all views except one that is AllButUpsideDown. 我有一个被锁定为在所有视图中均为人像的应用程序,除了AllButUpsideDown之外。 The approach i am using is to enable Portrait, Landscape Left and Landscape Right in the targets general settings menu. 我使用的方法是在目标的常规设置菜单中启用人像,左横向和右横向。 Then have subclasses of UINavigationController and UITabBarController that override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask and returns .Portrait . 然后具有UINavigationController和UITabBarController的子类,这些子类重写.Portrait func supportedInterfaceOrientations() -> UIInterfaceOrientationMask .Portrait并返回.Portrait

Then in my view controller that needs to be able to be rotated I have also overridden func supportedInterfaceOrientations() -> UIInterfaceOrientationMask and returns .AllButUpsideDown . 然后在需要旋转的视图控制器中,我还重写了.AllButUpsideDown func supportedInterfaceOrientations() -> UIInterfaceOrientationMask .AllButUpsideDown并返回.AllButUpsideDown This works fine since this view controller is only presented as a modal ie aViewController.presentViewController() . 由于此视图控制器仅作为模式(即aViewController.presentViewController()呈现,因此效果很好。

All of this work as expected on iOS9 on iOS8 however if i close the rotatable view controller while in landscape the UI will be scaled to landscape altho it will be displayed in portrait. 所有这些工作都可以在iOS8上的iOS9上按预期进行,但是如果我在横向模式下关闭可旋转视图控制器,则UI将按横向缩放比例,它将以纵向显示。

导致iOS8

Anyone know what to do about this? 有人知道该怎么办吗? Am I approaching this rotation thing wrong from the start? 我从一开始就走错了方向吗? Any clean fixes? 有干净的修补程序吗? Workarounds? 解决方法? Hacks? 黑客?

UPDATE UPDATE

My problem originated from me using a custom transition to present and dismiss the view controller that could rotate. 我的问题源于我使用自定义过渡来呈现和消除可能旋转的视图控制器的原因。 I tried to work around it for some time with bunch of different solutions. 我尝试使用一系列不同的解决方案解决了一段时间。 The closest I got to a solution was to use a separate UIWindow for my rotatable view controller, that worked except a issue with the carrier bar still being in the wrong orientation, and that was something I did not manage to solve. 我最接近解决方案的方法是为可旋转的视图控制器使用单独的UIWindow,该方法行之有效,只是载物栏仍处于错误方向,这是我无法解决的问题。

The solution(not really a solution) I went with was to only use the custom transition in iOS9+ and on iOS8 use the default present transition. 我采用的解决方案(不是真正的解决方案)是仅在iOS9 +中使用自定义过渡,而在iOS8上使用默认的当前过渡。

I had the similar issue when navigation back from VC, that supports landscape to the one that is only portrait. 从VC导航回来时,我遇到了类似的问题,该问题支持将风景模式仅支持纵向模式。 I didn't find a clean workaround. 我找不到干净的解决方法。 These couple of lines are not recommended to use, but if you are desperate you can force your device orientation when you are about to dismiss. 不建议使用以下几行,但是如果您不顾一切,可以在即将解散时强制设备定向。

let value = UIInterfaceOrientation.Portrait.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM