-2

UIImagePickerController should open in landscape? I tried using category but it is not working. how to fix orientation to a UIImagePickerController ?

Viral Savaj
  • 3,379
  • 1
  • 26
  • 39

3 Answers3

0

You should use UIPopoverController to display ImagePickerController in Landscape mode

-(void)showImagePicker:(id)sender
    {
        UIButton *button = (UIButton *)sender; // button is on which user will tap to show image picker
        UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
        imgPicker.delegate = self;
        imgPicker.allowsEditing = YES;
        imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

        self.popover = [[UIPopoverController alloc] initWithContentViewController:imgPicker];
        [self.popover presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    }
Vizllx
  • 9,135
  • 1
  • 41
  • 79
0

The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing.

0

It's easy. Try to create a custom class of UIImagePickerController. Override supportedInterfaceOrientations method in it:

- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL)shouldAutorotate{
    return YES;
}
Ptah
  • 906
  • 1
  • 12
  • 25