Search code examples
uiimagepickercontrolleruipopovercontroller

Why is the top of the scene on the right side of device's camera viewfinder for iPad Landscape only?


UIImagePickerController, UIPopoverController,iPad

Inside my app, the photo view and the photos taken are as expected in Portrait mode, i.e. HomeButton at the bottom. But with the iPad only, (iPhone is fine) if I use Landscape, and point the iPad camera at a ladder leaned up against the house, say from the ground to the eaves, the eaves are running vertically along the right side of the popOver camera view. That is, the popover camera viewer has rotated into the correct position (long side of viewer are parallel to the long sides of the device, but the image displayed is rotated 90 degrees right. How do I fix this problem?

Thanks for reading, Mark

- (IBAction)grabPhotoAction
{
   UIImagePickerController* imagePicker = [[UIImagePickerController alloc] init];
   imagePicker.delegate = self; 
   imagePicker.sourceType = (cameraSelected) ?
     UIImagePickerControllerSourceTypeCamera : UIImagePickerControllerSourceTypePhotoLibrary;
   if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
   {
       self.myPopover = [[classPopoverController alloc] initWithContentViewController:imagePicker];
       [myPopover presentPopoverFromRect:CGRectMake(0.0, 0.0, 400.0, 400.0)
           inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
   }else {
       [self presentViewController:imagePicker animated:NO completion:NULL];
   }

}


Solution

  • I found the answer online just before posting this question. I decided it might well be helpful to others. The answer is quite simple. Forget all about using the special treatment for iPad and simply display full screen for both iPhone and iPad.

    - (IBAction)grabPhotoAction
    {
        UIImagePickerController* imagePicker = [[UIImagePickerController alloc] init];
        imagePicker.delegate = self;
        imagePicker.sourceType = (_cameraSelected) ?
            UIImagePickerControllerSourceTypeCamera : UIImagePickerControllerSourceTypePhotoLibrary;
        [self presentViewController:imagePicker animated:NO completion:NULL];
     }