How does iPhone orientation change animation work?
-
I am Android developer and I'm curious how the nice orientation change in iOS apps done -- from developer and from iOS point of view. In Android, apps are restarted on orientation change, there's no animation. How hard would it be add support for this animaton to Android OS?
-
Answer:
For regular applications using the UIKit framework, the orientation animation is automatic. The application nominates (usually in the application properties in Xcode) which orientations are supported. (i.e. portrait, landscape-left, landscape-right, and upside-down). Then at runtime, of the accelerometer detects the user has changed the orientation, the application gets a message -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation so it can decide dynamically to allow certain rotations. The developer can also customise the layout of the user interface in the new orientation to optimise the sizing and positioning of interface elements. Interface Builder can be used to describe constraints which let the system automatically adjust the layout. If the system-derived layout is not enough, it can also be programmatically specified. This is described in the Apple iOS reference documentation: https://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/RespondingtoDeviceOrientationChanges/RespondingtoDeviceOrientationChanges.html If the application is an OpenGL app (for example, most games) the rotation must be done by the developer. This is relatively easy to do. The application needs to track the current and target rotation angle, and use a timer to adjust the increment and call glRotatef() in the drawing method. This is fully described in Chapter 1 of "iPhone 3D Programming" by Phillip Rideout. http://www.amazon.com/iPhone-Programming-Developing-Graphical-Applications/dp/0596804822/
Gavin Baker at Quora Visit the source
Other answers
In iOS there are methods (overridable) that are called before and after the orientation has changed.
Cesare Rocchi
Related Q & A:
- How To Get Online Data Mining Work?Best solution by theatlantic.com
- How to make Entity Framework migrations work?Best solution by Stack Overflow
- How to do references in Java work?Best solution by stackoverflow.com
- If you work in Kroger, how many hours do part-timer work?Best solution by Yahoo! Answers
- How to make a moving animation?Best solution by goanimate.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.