views:

693

answers:

2

I am using the UIImagePicker to access the camera on my iPhone app. I would like to be able to have two different overlays for the imagepicker, depending on the orientation of the iPhone. Is it possible to do this? It seems like if I place the following method in the class that owns the UIImagePickerController, it does not get called at all, and in any uiviewcontroller above that it only gets called once the UIImagePickerController is not active.

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
   NSLog(@"shouldAutorotate called");
   return YES;
}

Any idea how to achieve the desired effect?

+1  A: 

The documentation says that the UIImagePickerController only supports portrait mode so it could be that there's no supported way of doing this.

If you're using presentModalViewController:animated to display the imagepicker then I believe only the modal controller will get messages like shouldAutorotateToInterfaceOrientation.

Normally you might be able to subclass UIImagePickerController to override the appropriate methods, but it seems that subclassing isn't supported either.

I suspect that you're going to have to actually use UIAccelerometer and do manual view rotation on your overlay view in response to acceleration messages.

Edit:

Actually, try using [NSNotificationCenter addObserver: for UIDeviceOrientationDidChangeNotification.

Nimrod
A: 

Actually using the raw accelerometer data, you can determine when to swap out the overlay, so that did it!

Andres