Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application is enabled only to Portrait, but UIImagePickerController rotates in iOS6

Please note that the answer below - do not work for iOS6 so I still need an answer!

My application is enabled only for Portrait mode.

However, if I embed a UIImagePickerController inside as a subview, and rotate the device, the top and bottom bar stays in the same location, however UIImagePickerController does rotate.

How can I prevent it from rotating?

This is the code:

    [self.view.window addSubview:self.imagePickerController.view];
    self.imagePickerController.showsCameraControls = NO; 
    self.imagePickerController.view.frame = CGRectMake(0, 90, 320, 320);
    self.imagePickerController.allowsEditing = NO;

EDITED

I am using iOS6 where shouldAutorotate is not being calle

like image 587
Dejell Avatar asked Jan 21 '13 10:01

Dejell


1 Answers

Add this UIImagePickerController category in your class,

@interface UIImagePickerController(Nonrotating)
- (BOOL)shouldAutorotate;
@end

@implementation UIImagePickerController(Nonrotating)

- (BOOL)shouldAutorotate {

  return NO;
}

@end
like image 90
Anusha Kottiyal Avatar answered Nov 13 '22 19:11

Anusha Kottiyal