views:

3697

answers:

15

Hi,

I wrote simple code to test UIImagePickerController:

@implementation ProfileEditViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  photoTaker_ = [[UIImagePickerController alloc] init];
  photoTaker_.delegate = self;
  photoTaker_.sourceType = UIImagePickerControllerSourceTypeCamera;
  photoTaker_.showsCameraControls = NO;
}

- (void)viewDidAppear: (BOOL)animated {
  [self presentModalViewController: photoTaker_ animated: NO];
}

@end

And I'm getting strange warnings like the following:

2010-05-20 17:53:13.838 TestProj[2814:307] Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations. 2010-05-20 17:53:13.849 TestProj[2814:307] Using two-stage rotation animation is not supported when rotating more than one view controller or view controllers not the window delegate

Got any idea what this is about? Thanks a lot in advance!

+1  A: 

Well, you are presenting UIImagePickerController modally inside viewDidAppear of ProfileEditViewController.

Think about this. That means when ProfileEditViewController view appears, the UIImagePickerController appears, say later you dismiss UIImagePickerController and it goes back to ProfileEditViewController, then viewDidAppear is called again and UIImagePickerController appears, say later you dismiss UIImagePickerController and it goes back to ProfileEditViewController, then viewDidAppear is called again and.... you get the idea.

That warning is rather cryptic though, not sure if that is what it's trying to tell you. I would suggest making a button somewhere on the ProfileEditViewController that calls presentModalViewController and also make sure you have a way to dismiss the UIImagePickerController (I've never used it not sure if it has one automatically).

Tom
Thanks for the answer. I got your point and will fix the code properly, but those warnings are not because of that. I think it's related to two-step orientation change of the view controller, but I can't figure out how to get rid of them.
Kay
Yea, I think the code you posted might not be related to that warning, if you haven't seen this question already it might help.http://stackoverflow.com/questions/2048781/single-stage-vs-two-stage-animation-for-iphone-apps
Tom
+1  A: 

I am having the same issue and after looking at what triggers the error messages, we can see that it is coming from the following line of code:

[self presentModalViewController: photoTaker_ animated: NO];

It looks like it is coming from the view "photoTaker_", therefore it is related to the implementation of the class UIImagePickerController and we cannot do anything about it.

Are you using the OS version 4.0?

ErezSO
Yes.. for me it was a problem of iOS4 beta, and it went away after getting back to 3.1.3. Not sure the recent 4.0 release still has the same problem..
Kay
A: 

I am also having same problem. I checked it both on iPhone OS version 3.2 and iPhone version 4.0.

Sali
+1  A: 

Having the exact same problem here...could it be that something in the SDK changed and they haven't yet updated the UIImagePickerController class?

Anyone else have some troubleshooting tips? On my app, it is generated from the same line which presents the imagepicker as a modal controller. Tried it with animated:YES and animated:NO with no difference.

Jim
A: 

I just noticed that I am getting these same warnings in my app right before it crashes. User is taking photos, these warnings appear, app starts getting warned about memory over and over very quickly, then app crashes.

This is a new part of the codebase for me. Could be that the code is doing bad stuff with memory here after photos are taken...

toofah
+1  A: 

Same here... bt on the stack indicates that I get an objc_exception_throw in a routine called

1 0x00517692 in UIImagePickerEnsureViewIsInsidePopover ()

Not sure if image picker has to open in a popover... are you guys targeting iPad/iPhone or both. I'm working on the iPad.

jklm
There seem to be a couple of different issues on this thread... BUT if you are writing for the iPad you need to put the image picker in a UIPopoverController as the content view. Otherwise you get the "Using two-stage rotation animation is not supported when rotating more than one view controller or view controllers not the window delegate" and a crash.Hope this helps.
jklm
For me it was a problem of iOS4 beta, and it went away after getting back to 3.1.3. Not sure the recent 4.0 release still has the same problem.. But thanks for the heads-up!
Kay
A: 

This morning I had the same problem in my app: I selected a button, made a pic and got the message described above with memory warnings too.

Never had before iOS 4.0; I realized that my iPhone was on since yesterday, I rebooted and it works fine managing pictures (but I still have Using two-stage rotation animation message).

So to me it's a memory issue with iOS 4.0 but I can not image how to deal with it. Have to tell the users that it might be memory issues with iOS 4.0 ? :-)

Fabrizio

Fabrizio
A: 

I have a UIToolbar on my view and I call the camera using the standard code. I get the same two messages.

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

(2) Using two-stage rotation animation is not supported when rotating more than one view controller or view controllers not the window delegate.

Besides the UIToolbar covering up my camera controls, me thinks the toolbar is the first rotation and then the camera call is the second rotation...whatever this means.

Still trying to get rid of my custom toolbar thinking it will fix these messages.

MadProfit
A: 

I have just discovered this warning and cannot get rid of it and have looked thru Google with no joy!

Even if I restrict to one orientation in landscape I still get the warnings.

Also I notice that if I tap the button when in landscape mode to present the imagepickercontroller it displays OK but when I rotate the phone to portrait to view the imagepickercontroller correctly the view flashes momentarily as if trying to rotate from landscape to portrait????

user7865437
A: 

Update. This "two stage / one stage" still persists in my app but does not crash the app so I still would appreciate answers or the real cause from some expert developers or somebody at Apple.

As a side item, one would think that when someone wrote the C code or Xcode that some sort of documentation would have been written for each warning or error message with some guidance as to the cause.

MadProfit
A: 

I think the warning here is about Core Animation performance. As a test, I loaded the image picker without any action sheet or other animations going on and the warnings are still there. I think these are warnings coming from the image picker class itself and not from any misuse of the API.

David Weiss
A: 

I encounter the same warning. The UIImage,obtained from UIImagePickerController,in iOS 4.0 is different with that in iOS 3.1.x. Some imageOrientation problem will happen under iOS 4.0, but no problem under iOS 3.1.x.

Toro
A: 

You may be trying to present two modal view controllers at the same time, and they are fighting for animation resources.

1) There is rarely any UI reason to do this. You could instead just go directly to the second view controller (the image picker); and, after dismissing it, then present the first view or view controller.

2) If you do want two stacked view controllers or a view controller on top of a view, then set a timer in viewDidAppear to present the second view controller after the first one has finished it's animation. (You could display a dummy png image of a blank picker in the first one to prevent too much display flashing until the second view controller goes live.)

EDIT - Added a random code example:

I might try substituting this as an experiment:

- (void)foo {
    [self presentModalViewController: photoTaker_ animated: NO];
}

- (void)viewDidAppear: (BOOL)animated {
    NSTimer *bar = [ NSTimer scheduledTimerWithTimeInterval: (2.0f)
                             target: self  
                             selector: @selector(foo)
                             userInfo: nil
                             repeats:NO ];
}

A shorter time delay may work as well.

hotpaw2
This post is speaking specifically about UIImagePickerController, which appears to always cause this warning. Provide a working example of UIImagePickerController that avoids the warning in iOS 4.1, and I'll award you the bounty!
Peter DeWeese
+1  A: 

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?

rpetrich
It works only because it doesn't animate. Any method that avoids animation will avoid the warning, but the intent is for full slide on functionality without the annoying warning. Maybe windows will be the answer somehow.
Peter DeWeese
Alright, it works if I create a new window, add the picker as the rootViewController of that window, and then animate within that window. I'm adding an answer to that effect. I'll give you the bounty since you triggered the thought that led to a solution!
Peter DeWeese
A: 

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];
    }

John Carter