Saturday, January 15, 2011

iPhone dev Stupidity 136: Two stage animation warning

Since iOS 4.0 you got this warning when present a camera picker controller:

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

The real cause is from stackoverflow:
This message will appear if you have are presenting the UIImagePickerController within another UIViewController. Because it isn't pushed like a UINavigationController stack, there is confusion at the UIWindow level. I don't know if the warning is a problem, but to eliminate the warning you can do the following:

// self = a UIViewController
//

- (void) showCamera
{
cameraView = [[UIImagePickerController alloc] init];
[[[UIApplication sharedApplication] keyWindow] setRootViewController:cameraView];
[self presentModalViewController:cameraView animated:NO];
}

- (void) removeCamera
{
[[[UIApplication sharedApplication] keyWindow] setRootViewController:self];
[self dismissModalViewControllerAnimated:NO];
[cameraView release];
}

There’s also a good point for iOS 4.x:

Perhaps you are adding the root UIViewController's view as a subview of the window instead of assigning the view controller to the window's rootController property?

No comments: