Forums : A note an rotation implementation on iOS
This page last changed on Oct 05, 2011 by ebariaux.
Reviewing the implementation of the rotation management code on iOS took me quite a bit of time (and I still need to fix a couple of issues).
Rotation management is nicely handled by iOS, who mostly does all the work for you. So why is it so hard in OpenRemote?
The issue is that once you are using the UIViewController class and its mechanisms, you need to follow the guidelines setup by Apple, which means:
While the last point makes sense for most applications, this is where the issue comes in for OpenRemote.
The existing implementation did try to mix both the automatic rotation code provided by iOS and custom rotation code. More precisely, it would decide to let or forbid the system from auto-rotating the interface based in the available OR screens. From what I saw, this lead both to complex code and to the fact that in some edge cases, the automatic / manual mechanism would get "out of sync" and the display would get screwed.
Another solution I did explore is to tell iOS to never managed the rotation for OR screens and to manage it manually in our code. While this does work fine for all OR screens, once you want to pop-up an "application screen" (like settings or login) and you use the iOS standard mechanism to do so (e.g. presentModalViewController: ), the system is lost because of the custom transform in place, resulting in the default animations not being correct (e.g. slide from side instead of bottom) and the OR screen getting screwed on dismiss (because iOS tries to restore you to the state it thought you were in before).
The solution I finally settled for is to always let the system perform the rotation on a top level view and embed our own child view in it. Then, depending on the OR screen that needs to be displayed, I "correct" the rotation on the child view. This seems to work great so far but has one draw back. As the system does the rotation for us, the UI does rotate with an animation, then "jumps" back to what it should be. I'm not sure I'll be able to fix that (I might be when talking to CoreAnimation directly, but not sure).
|Document generated by Confluence on Jun 05, 2016 09:29|