简体   繁体   English

这是iOS 8 Bug(轮换方向问题)吗?

[英]Is this an iOS 8 Bug (orientation issue on rotation)?

since iOS 8 my App runs quite good, but I found a Problem while testing this app. 从iOS 8开始,我的App运行得非常好,但是在测试这个应用程序时我发现了一个问题。 It just happens on iPad and only if I launch the app in landscape mode. 它只发生在iPad上,只有我在横向模式下启动应用程序。 If it launches in Portrait everything is right(no rotation issues). 如果它在Portrait中启动,一切都是正确的(没有旋转问题)。 If i rotate the Device (simulator or real device) the view rotates out of the screen and just shows a Cut of the real view and the rest is black. 如果我旋转设备(模拟器或真实设备),视图将旋转出屏幕,只显示实际视图的剪切,其余为黑色。

在此输入图像描述

在此输入图像描述

Anyone else did notice such a bug? 其他人确实注意到这样的错误? How can I fix it? 我该如何解决?

Had similar problem. 有类似的问题。 Surprisingly the fix was to comment out all the code related to self.window on Appdelegate. 令人惊讶的是,修复是在Appdelegate上注释掉与self.window相关的所有代码。

Commented initialising of self.window and its assignment. 评论self.window及其赋值的初始化。 Set the initial view in storyboard in Attributes inspector by checking "Is Initial View Controller" checkbox. 通过选中“是初始视图控制器”复选框,在“属性”检查器中设置故事板中的初始视图。

New Better Solution 更好的解决方案
Commenting self.window was causing other issues. 评论self.window引起了其他问题。 Instead the below code is best: 相反,以下代码是最好的:

- (void)applicationDidChangeStatusBarOrientation:(NSNotification *)notification 
    {
         [UIViewController attemptRotationToDeviceOrientation];
    }
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
BOOL landscape = (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight);
NSLog(@"Currently landscape: %@, width: %.2f, height: %.2f", 
      (landscape ? @"Yes" : @"No"), 
      [[UIScreen mainScreen] bounds].size.width, 
      [[UIScreen mainScreen] bounds].size.height);

And the results are: For iOS 8+ 结果是:适用于iOS 8+

Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 568.00, height: 320.00

and for iOS 7- 适用于iOS 7-

Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 320.00, height: 568.00

It seems like there is a change in the way height and width of the screen is handled while in portrait and landscape from ios8 onwards. 从ios8开始,纵向和横向处理屏幕的高度和宽度的方式似乎有所变化。

Check this link Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8? 检查此链接是否[UIScreen mainScreen] .bounds.size在iOS8中变为取向依赖?

UPDATE - We found a fix: 更新 - 我们发现了一个修复:

I found the answer to our problem which as described below appeared to be exactly the same as yours. 我找到了问题的答案,如下所述,与你的问题完全相同。 One of our other developers noticed an "unexpected nil in main window" when attempting to tap on the far right of the screen. 当我试图点击屏幕的最右侧时,我们的其他开发人员注意到“主窗口中出现意外的零”。 This led me to do a new search and I found this thread on stackoverflow that actually contained the answer to our problem. 这导致我做了一个新的搜索,我发现stackoverflow上的这个线程实际上包含了我们问题的答案。

( here is the link to the question which help my answer: unexpected nil window in _UIApplicationHandleEventFromQueueEvent ) (这是帮助我答案的问题的链接: _UIApplicationHandleEventFromQueueEvent中的意外nil窗口

The actual answer came from frankish who suggested opening the main.xib (or main storyboard) and clicking on the Window in that and making sure that the "Visible at Launch" and "Full screen at Launch" properties are checked (set to true.) 实际答案来自frankish,他建议打开main.xib(或主要故事板)并单击其中的Window并确保选中“在启动时可见”和“启动时全屏”属性(设置为true)。 )

In our case, it was JUST the "Full screen at Launch" property that needed to be set, but setting this fixed the rotation problem we were seeing AND it fixed an issue where when launching on iPad in landscape the far right of the screen was not touchable. 在我们的例子中,它只是需要设置的“启动时全屏”属性,但设置这个固定我们看到的旋转问题并且它修复了一个问题,当在屏幕的最右边的横向上在iPad上启动时不可触摸。

END UPDATE - (original non-answer below) END UPDATE - (原始非答案如下)

My answer isn't an answer, but I have run into the exact same issue. 我的答案不是答案,但我遇到了完全相同的问题。 On rotate in our app, when building with Xcode 6, I see the exact same rendering issue as the the screenshots on this question. 在我们的应用程序中旋转时,使用Xcode 6进行构建时,我会看到与此问题的屏幕截图完全相同的渲染问题。 The exact same out of position rotate with black bars at the side and bottom. 完全相同的位置旋转,侧面和底部带有黑条。 (Our app on iPhone doesn't support any rotation so we don't see the issue on iPhone. On iPad we support landscape left and landscape right. When rotating from one to the other, when the iPad does it's standard rotation animation, it will rotate out of position (showing the black bars) when going one way and then rotate back into proper position when going back to the other supported orientation. I don't believe it's related to any custom positioning or animation code. It happens with every screen, including the splash screen. It appears to be related to the built in Apple screen rotation. Obviously not every project has this issue in iOS but I have not come across the particulars that are causing this issue. I spent all day yesterday researching the issue and going through our code and I have nothing. (我们在iPhone上的应用程序不支持任何轮换,因此我们在iPhone上看不到问题。在iPad上我们支持横向左侧和横向右侧。当从一个旋转到另一个时,当iPad执行它的标准旋转动画时,它当走一条路时会旋转到位(显示黑条),然后在回到另一个支持的方向时旋转回到正确的位置。我不相信它与任何自定义定位或动画代码有关。它发生在每一个屏幕,包括启动画面。它似乎与内置的Apple屏幕旋转有关。显然不是每个项目在iOS都有这个问题,但我没有遇到导致这个问题的细节。我昨天花了一整天研究问题并通过我们的代码,我什么都没有。

One piece of additional info. 一条附加信息。 If I build with Xcode 6 and run on a device with iOS 7 then there is not issue. 如果我使用Xcode 6构建并在iOS 7设备上运行,则没有问题。 This issue ONLY happens when I build with Xcode 6 and run on a device with iOS 8. 这个问题只发生在我使用Xcode 6构建并在iOS 8设备上运行时。

Here is a link to my own question posted yesterday about this issue. 这是我昨天发布的有关此问题的问题的链接。 (I did not come across this question until after I'd posted my question.) (在我发布问题之前,我没有遇到过这个问题。)

Building project with Xcode 6 (iOS 8 SDK) causes landscape rotation rendering issue on iPad 使用Xcode 6(iOS 8 SDK)构建项目会导致iPad上出现横向旋转渲染问题

I found this to be an issue when I had multiple windows in my application. 当我在我的应用程序中有多个窗口时,我发现这是一个问题。 By setting a breakpoint on -[UIWindow setFrame:] , I was able to see that upon rotation, the system was giving me giving me an erroneous frame size and position. 通过设置断点-[UIWindow setFrame:] ,我能够看到在旋转时,系统给了我一个错误的帧大小和位置。 You can get around this by manually setting your frame to equal [UIScreen mainScreen] bounds] which seems to be correct if you running on iOS7+ and compiling with Xcode6. 您可以通过手动将帧设置为等于[UIScreen mainScreen] bounds]来解决这个问题,如果您在iOS7 +上运行并使用Xcode6进行编译,这似乎是正确的。 I found that doing this in -[UIWindow becomeKeyWindow] worked well for me: 我发现在-[UIWindow becomeKeyWindow]中这样做对我-[UIWindow becomeKeyWindow]

- (void)becomeKeyWindow {
    [super becomeKeyWindow];

    self.frame = [UIScreen mainScreen].bounds;
}

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

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