Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPad 2 UIImagePickerController camera auto-rotation driving me mad!

I've been trying to sort this one out for a while and getting nowhere.

I'm using the camera on the iPad 2 - my application is in landscape, but I want to use the camera in portrait mode. I just can't seem to force the ImagePicker a, into Portrait mode, and b, to stop auto-rotating.

Is there any way that you can force the ImagePicker into portrait (or landscape), and/or to stop it auto-rotating?

Even though the App is in landscape and is set to return YES only to landscape orientations, the ImagePicker ignores that and rotates into portrait when you rotate the iPad 2.

If I could force it into staying in landscape then (although not ideal) I could re-design the app to use the camera in landscape, but I don't seem to be able to do even that!

Any help greatly appreciated!

like image 871
Matt Avatar asked May 15 '11 09:05

Matt


1 Answers

The method that you need to override called:

_isSupportedInterfaceOrientation:

So it should look something like this :

@interface PortraitImagePickerController : UIImagePickerController {

}

@end





@implementation PortraitImagePickerController
- (BOOL)_isSupportedInterfaceOrientation:(UIDeviceOrientation)orientation{
    return UIDeviceOrientationIsPortrait(orientation);
}
@end

But it's definitely private method so Apple may reject your app

like image 188
Dmitry Avatar answered Jan 02 '23 09:01

Dmitry