Every September now, means pain for the IOS developers. Because you need does not have to update to the latest iOS system, but also to support old iOS versions with newer version SDK. More stuff coming, equally amount of stuff deprecated.
This bug I encountered was IOS 6.0 only, because game Center only have portrait view, it'll break landscape only games Bec Ause they don ' t support the orientation.
Xcode would error out something about autorotate which isn ' t the real cause.
People say Apple fixed this bug for later version of IOS 6. But the workaround-issue is-to-support Portrait view on UIWindow, but limit the rootviewcontroller by setting up The landscape mask.
In order to access a uiapplication, we need to does it from Uiapplicationdelegate, the delegate class has a uiwindow, and th E UIWindow have a rootviewcontroller (after IOS 4.0), and you can add your UIView as Subview to Rootviewcontroller.
This is the quite normal for any 2D based display system, and you'll need to a display container hierarchy anyway.
Everything works fine, problem seems to solved.
However, Google mobile ad SDK interstitial triggered this rotation malfunction. Some interstitials has both landscape view and portrait view, even thought the interstitial starts with the current Orien Tation, if you rotates, it'll automatically sync. Since We have the enabled the portrait view in UIWindow and now this interstitial could rotate. It's fine, but when you close it, the game mistakely got rotated, even tho the rootviewcontroller only have landscape views .
For some reason the interstitial are added to UIWindow directly, instead of add to rootviewcontroller like banners do. Part of the reason might being the Google Mob Ad Sdk Interstitial class is not derived from Uiviewcontroller, instead it Deri Ved from nsobjects directly. Anyway, I tried to add the Interstialviewcontroller directly to Rootviewcontroller and Presentviewcontroller, the inte Rstitial is cut off only showing up 1/3 of the screen. In another trial, the UI input is disabled. After all, both ways ended up with the interstitial are still rotatable, which causing the game play to rotate.
Some people suggested to use Uinavigationcontroller and set those rotation related functions. It doesn ' t seem to work since this app was really really really fucking old, it isn ' t even using Storyboard at all. Tried to change class declaration for Rootviewcontroller or Interstialviewcontroller, no luck.
What makes it even harder to debug are, if this are a native or modern IOS app, I could do everything in the project, adding Flags checks. But the this app was using our internal framework, Appdelegate is a static libarary class, otherwise I could add a game center Flag check directly and control the Supportedorientation for window accordingly.
Plus, certain functions, for example the accelerometer and rotation function made by the Framwork group seems to be Workin g in parallel with the IOS system level function, but they is out of sync, the core functions cannot detect the portrait Orientation, it simply ignores it!
So after digging out more stackoverflow posts, people mentioned using SetOrientation, or manually change the rotation. This was an unofficial or non-public interface, people still doing it. We cannot depend everything on IOS itself. So my final solution to this is:in willdissmissinterstitial function, manually rotate the window degree secretly. This works fine, nobody knows until I tell them. (BTW, if you put the it in Diddismiss function, you'll notice a glitch)
So.. Anyway, just to log. The end of a 3 day torture.
IOS Orientation Bug