Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIImagePickerController overlay autorotate

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?

like image 363
Andres Avatar asked Oct 26 '22 23:10

Andres


1 Answers

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.

like image 86
Nimrod Avatar answered Nov 15 '22 08:11

Nimrod