IOS 8 supports external interfaces, although shouldAutoRotate = NO; the view is still spinning

I have an application designed to run Landscape. This is a Cocos2D application. It works fine until I add another window (for example, to show ads) or if I show a modal view controller.

When I do this, the window / view still rotates, although I have a set of explication shouldAutoRotate = NO

In addition, Apple says that supportedInterfaceOrientations will not be called if shouldAutorotate returns NO. However, it is called both before and after it is calledAutorotate. Why is this happening and what is the solution for controlling auto-rotation in iOS 8?

While I saw many SO issues related to auto-rotation issues in previous versions of iOS (with the most detailed description of how to set up autorotation control found in shouldAutorotateToInterfaceOrientation is not called in iOS 6 ), none of them seem to affect support problem for called interfaces, although shouldAutoRotate = NO; and the view is still spinning, even if it is told not to spin.

To fully understand my explanation, here is a description of how I installed it:

Firstly, in order to display the launch images, I had to set the device orientation to info.plist to support all orientations. Otherwise, the screen turns black at startup.

Next, here is how my code is implemented:

 - (void) applicationDidFinishLaunching:(UIApplication*)application { ... // Init the 2nd window secondWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // secondWindow is defined as a UIWindow // Init the second View Controller nrViewController = [[NonRotatingViewController alloc] initWithNibName:nil bundle:nil]; // nrViewController is defined as a UIViewController nrViewController.wantsFullScreenLayout = YES; // this insures that if the status bar it transparent, the view underlaps it [secondWindow setRootViewController:nrViewController]; // The root view controller provides the content view of the window. [secondWindow addSubview: nrViewController.view]; // Adds a view to the end of the receiver's list of subviews [secondWindow makeKeyAndVisible]; // make the receiver the main window and displays it in front of other windows EAGLView *glView = [EAGLView viewWithFrame:[secondWindow bounds] pixelFormat:kEAGLColorFormatRGB565 // kEAGLColorFormatRGBA8 depthFormat:0 // GL_DEPTH_COMPONENT16_OES ]; // attach the openglView to the director CCDirector *director = [CCDirector sharedDirector]; [director setOpenGLView:glView]; [director setDeviceOrientation:kCCDeviceOrientationLandscapeRight]; // make the OpenGLView a child of the view controller [nrViewController setView:glView]; // bug fix requires a non-rotating view controller and window on top of a rotating one. } 

The NonRotatingViewController in the second window returns NO when calling the Functionotate function. It also returns 0 with the support of InterfaceOrientations (although it doesn't technically matter what I return because Apple says it should not be called).

For the modal view controller and the ad review controller, I tried both shouldAutorotate = NO and YES. None of the approaches will force the rotation of the second window / nrViewController. I spent days trying all kinds of combinations, but none of them work. Do you see what I can do wrong?

So, to repeat my question, why is InterfaceOrientations supported, called and why does the display still rotate, although shouldAutoRotate = NO?

+5
source share

Source: https://habr.com/ru/post/1203960/


All Articles