iOS Orientation bug
Every September means pain for iOS developers- you need to make sure your old apps/code run on the new iOS system/Apple devices, as well as update the iOS SDK, deprecate your code, API, etc. And ready to comply with whatever requirements Apple asks for.
This bug I encountered is iOS 6.0 only, on which Game Center has portrait view only. When API is being called, it will crash on landscape only games.
Xcode will error out something about autoRotate which isn't the real cause.
People say apple fixed this bug for later version of iOS 6.
The workaround I came up, is to support Portrait view in UIWindow, but disable it in the rootViewController by setting up the landscape mask.
In order to access a UIApplication, we need to do it from UIApplicationDelegate, the delegate class has a UIWindow, and the UIWindow has a rootViewController (after iOS 4.0), and you can add your UIView as subview to rootViewController.
(This is quite normal for any 2D based display system, you will need to have a display container hierarchy anyway.)
Everything works fine, problem seems to solved...
However, google mobile ad sdk interstitial triggered this rotation malfunction. Some interstitials have both landscape view and portrait view, even though the interstitial starts with the current orientation, if you rotate the screen to portrait view, the interstitial will automatically rotate to portait view. Because portrait view is possible in UIWindow.
Now when you close the ad, the game mistakely got rotated, even tho the rootViewController only has landscape views.
For some reason interstitials are added to UIWindow directly, instead of being added to rootViewController like banners are. Part of the reason might be that Google Mob Ad Sdk interstitial class is not derived from UIViewController, it derives directly from NSObjects. So I've tried to add the InterstialViewController directly to rootViewController and presentViewController, now the interstitial is cut off and only shows up 1/3 of the screen. In another trial, the UI input is disabled. After all, both ways ended up with the interstitial being rotatable, which causes the game play to rotate.
Some people suggest use UINavigationController and set those rotation related functions. It wouldn't work because this app is really really really f**king 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 is, if this is a native or modern iOS app, i could do everything in the project, adding flag checks. But this app is 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 working in parallel with the iOS system level function, but they are 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 is an unofficial/non-public interface. We cannot depend everything on iOS itself. So my final solution for this is: in willDissmissInterstitial function, manually rotate the window 90 degree secretly. This works fine, nobody knows until i tell them. (btw, if you put it in didDismiss function, you will notice a glitch)
iOS Orientation bug的更多相关文章
- 讲述Sagit.Framework解决:双向引用导致的IOS内存泄漏(中)- IOS不为人知的Bug
前言: 话说昨晚还是前晚,写了一篇:讲述Sagit.Framework解决:双向引用导致的IOS内存泄漏(上) 文章写到最后时,多了很多莫名奇妙的问题!!! 为了解决了这些莫名奇妙的问题,我又战斗了2 ...
- iOS Orientation获取
[iOS Orientation获取] 1.[[UIDevice sharedInstance] orientation] 必须调用beginGeneratingDeviceOrientationNo ...
- IOS Orientation, 想怎么转就怎么转~~~
此博文主要针对IOS应用, 是屏幕旋转相关问题的一个总结. 主要内容有: IOS5,6,7不同版的适配. 强制旋转和自动旋转. 博客: http://www.cnblogs.com/jhzhu 邮箱: ...
- iOS 证书Bug The identity used to sign the executable is no longer valid 解决方案
现象:The identity used to sign the executable is no longer valid Please verify that your device’s cloc ...
- ios 刷新BUG
UItextView edited = yes ; 导致 刷新奇怪: 有些方法不要自己调用: 可能会破坏组件自己的生命周期: 建议模块化开发组件,自己处理自己的事:
- ios模拟器bug
Error: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Libra ...
- iOS开发-Bug锦囊
duplicate symbols for architecture armv7 今天修改了自己项目的部分代码,发现XCode编译的时候报错:duplicate symbols for archite ...
- ios问题bug收录——1
**[2713:59682] *** Assertion failure in -[MBProgressHUD show:], /Users/lu/Desktop/****/Pods/MBProgr ...
- VUE: 移动端长按弹出确认删除地址(后面测试发现IOS有BUG,后面有更新随笔,更新后的亲测有效)
收货地址的删除方式可能有很多种,我目前见过的暂时只有两种(1.在编辑页删除 2.长按某一条收货地址弹出是否删除地址) 在开发的项目上要求第二种删除方法,于是记录一下我写的代码 ~ 1.首先,在移动端 ...
随机推荐
- [并查集] POJ 1703 Find them, Catch them
Find them, Catch them Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 43132 Accepted: ...
- sublime简书安装配置
sublime-text3编辑器 安装 sudo add-apt-repository ppa:webupd8team/sublime-text-3 sudo apt-get update sudo ...
- 简易线程池Thread Pool
1. 基本思路 写了个简易的线程池,基本的思路是: 有1个调度线程,负责维护WorkItem队列.管理线程(是否要增加工作线程).调度(把工作项赋给工作线程)等 线程数量随WorkItem的量动态调整 ...
- SQL疑难问题
最近,遇到并解决一个SQL上的疑难问题.考勤系统,记录着员工进出公司的刷卡记录.而员工刷卡并不规范,存在刷多次的情况.例如:出去时连续刷多次,进来时也连续刷多次.筛选有效刷卡记录数据的规则:对于出去时 ...
- 嵌入式Linux的调试技术
本节我们研究嵌入式Linux的调试技术,对于复杂的Linux驱动及HAL等程序库,需要使用各种方法对其进行调试.刚开始讲了打印内核调试信息:printk,这个函数的用法与printf函数类似,只不过p ...
- DLL 导出封装类
首先使用Wizard创建一个Win32 Dynamic-Link Library工程,然后定义一个简单的C++类CInDLL.由于该类会被工程之外的文件所引用,所以需要对这个类进行引出.因为只有引出后 ...
- Linux学习 :移植linux-4.7.4到JZ2440开发板
一.编译环境搭建: 1.linux源码下载:https://www.kernel.org/2.安装交叉编译工具链: ①手动下载配置工具链: (1):解压 arm-linux-gcc-3.4.1.tar ...
- Console命令详解,让调试js代码变得更简单
Firebug是网页开发的利器,能够极大地提升工作效率. 但是,它不太容易上手.我曾经翻译过一篇<Firebug入门指南>,介绍了一些基本用法.今天,继续介绍它的高级用法. ======= ...
- Informatica Lookup Transformation组件的Connect 与Unconnected类型用法
Informatica Lookup Transformation组件的Connect 与Unconnected类型用法及区别:下面是通一个Lookup在不同Mapping中的使用: 1. Conne ...
- 关于linq to sql类线程同步问题
例如,下面一段代码,当两个线程同时访问时会出现各种由于线程不同步而导致的问题,比如什么DataReader已打开未关闭啊,已经添加了重复的键啊等等. /// <summary> /// 当 ...