Single-Stage vs Two-Stage Animation for iPhone Apps?

20,944

Solution 1

Everything is explained in the UIViewController Class Reference. Especially check out the View Rotation section near the top.

From the reference:

Handling View Rotations

By default, the UIViewController class displays views in portrait mode only. To support additional orientations, you must override the shouldAutorotateToInterfaceOrientation: method and return YES for any orientations your subclass supports. If the autoresizing properties of your views are configured correctly, that may be all you have to do. However, the UIViewController class provides additional hooks for you to implement additional behaviors as needed.

To temporarily turn off features that are not needed or might otherwise cause problems during the orientation change, you can override the willRotateToInterfaceOrientation:duration: method and perform the needed actions there. You can then override the didRotateFromInterfaceOrientation: method and use it to reenable those features once the orientation change is complete.

If you want to perform custom animations during an orientation change, you can do so in one of two ways. Orientation changes used to occur in two steps, with notifications occurring at the beginning, middle, and end points of the rotation. However, in iPhone OS 3.0, support was added for performing orientation changes in one step. Using a one-step orientation change tends to be faster than the older two-step process and is generally recommended for any new code.

To add animations for a one-step orientation change, override the willAnimateRotationToInterfaceOrientation:duration: method and perform your animations there. To use the older two-step method, override one or both of the willAnimateFirstHalfOfRotationToInterfaceOrientation:duration: and willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration: methods to configure your animations before each step. You must choose only one technique and override just the methods associated with that technique. If you override either method associated with the two-step technique, the view controller uses that technique by default.

Solution 2

I changed from willAnimateFirstHalfOfRotationToInterfaceOrientation:duration: method to willAnimateRotationToInterfaceOrientation:duration: method and warning gone.

Thanks.

Solution 3

I have found the culprit in my case to be the UIImagePickerController (I also do not override any rotation animation):

[self presentModalViewController:imagePicker animated:YES];

Replacing imagePicker with a generic UIViewController doesn't generate any warnings.

Solution 4

If you're using iOS 4 and you're getting this warning, I found a way to get rid of it. In your info.plist, there is an item called "Supported interface orientations." Select which orientations your application supports and two-stage warnings will go away when bringing up the imagePicker.

Solution 5

I've had this issue after creating a tabbarcontroller with no view controllers inside (no tabs), this warning disappeared once I attached at least one view controller to it.

Share:
20,944
seth-1
Author by

seth-1

Updated on July 25, 2022

Comments

  • seth-1
    seth-1 almost 2 years

    What are single-state and two-stage animation for rotating an iPhone window?

    This is the "error" message I get in the Debugger Console (nothing crashes):

    Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
    

    I was working through the book "Beginning iPhone Development: Exploring the iPhone SDK" by Apress (Dave Mark, Jeff LaMarche) on the Swap Project.

  • typeoneerror
    typeoneerror almost 14 years
    Unfortunately this doesn't help. I'm not using any of the orientation features and this error still happens. Appears to be a bug in OS4.
  • karim
    karim over 13 years
    I have the same problem for UIImagePickerController. Is there any other way to remove the error without changing it to UIViewController?
  • Adam
    Adam over 13 years
    This answer is correct for some situations, but not others. Certainly, that section in docs DOES NOT explain the error fully - there are specific bugs in Apple's UIImagePickerController / presentModalController that are triggering this error message (and which SHOULD NOT trigger it). Still trying to find a workaround :(.
  • Joze
    Joze over 13 years
    How did you specify the parameters of the UIImagePickerController using a UIViewController??
  • geon
    geon about 13 years