23

My image picker view controller setted inside popover controller. On iOS 6 everything works great, but on iOS 7 the image is rotated and all movings are doing verse: when turning iPad left image is going down, when moving up image going left, etc.

Here is the code for showing my camera:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.delegate = self;
    imagePicker.sourceType =  UIImagePickerControllerSourceTypeCamera;

    objPopView = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
    [objPopView presentPopoverFromRect:CGRectMake(842, 163, 0, 0)
                                inView:self.view
              permittedArrowDirections:UIPopoverArrowDirectionRight
                              animated:YES];

My app uses only landscape mode, now image is rotated: enter image description here

aparesidam
  • 309
  • 2
  • 13

3 Answers3

17

As the Apple's Official Doc said:

Present the user interface. On iPhone or iPod touch, do this modally (full-screen) by calling the presentViewController:animated:completion: method of the currently active view controller, passing your configured image picker controller as the new view controller.

On iPad, the correct way to present an image picker depend on its source type, as summarized in this table:

  • Camera Photo: Use full screen
  • Library Saved: Must use a popover
  • Photos Album: Must use a popover

...

On iPad, if you specify a source type of UIImagePickerControllerSourceTypeCamera, you can present the image picker modally (full-screen) or by using a popover. However, Apple recommends that you present the camera interface only full-screen.

Though it said "you can present the image picker modally (full-screen) or by using a popover", as you see by using a popover will result with this weird issue. I guess this might be a bug on iOS 7 SDK.

I'm still trying to fix this issue, but for now, the only way I can tell is to show it modally by

-presentViewController:animated:completion:

method, which is in full-screen (Actually, I don't like this way).

And there's a THREAD discussed about it on Apple's Dev Forums, you can take a look at it. ;)

Community
  • 1
  • 1
Kjuly
  • 34,476
  • 22
  • 104
  • 118
  • there should be some work around for resolving this.. do any one know? – Tarun Nov 20 '13 at 07:28
  • @Tarun not yet, I just chose to show fullscreen for this case. I'll update this answer when I've got a better solution. :) – Kjuly Nov 20 '13 at 07:29
  • why dont you use AvFoundation instead of UIImagePicker? – Vidhyanand Feb 11 '14 at 06:47
  • @Vidhyanand Sorry, why? As u see, _"AV Foundation is one of several frameworks that you can use to play and create time-based audiovisual media. It provides an Objective-C interface you use to work on a detailed level with time-based audiovisual data."_ – Kjuly Feb 11 '14 at 08:24
  • Thanks for the information. I guess I will have to use full screen for camera. Not many choices to me. I tried everything. – Emmy Mar 03 '14 at 04:29
  • @Emmy u'r welcome. Yes, seems fullscreen for taking photo via camera is the best choice right now :) – Kjuly Mar 03 '14 at 05:26
6

Try the following:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =  UIImagePickerControllerSourceTypeCamera;

CGFloat scaleFactor=1.3f;

switch ([UIApplication sharedApplication].statusBarOrientation) {

    case UIInterfaceOrientationLandscapeLeft:

        imagePicker.cameraViewTransform = CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI * 90 / 180.0), scaleFactor, scaleFactor);

        break;

    case UIInterfaceOrientationLandscapeRight:

        imagePicker.cameraViewTransform = CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI * -90 / 180.0), scaleFactor, scaleFactor);

        break;

    case UIInterfaceOrientationPortraitUpsideDown:

        imagePicker.cameraViewTransform = CGAffineTransformMakeRotation(M_PI * 180 / 180.0);

        break;

        default:
            break;
    }

objPopView = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[objPopView presentPopoverFromRect:CGRectMake(842, 163, 0, 0)
                            inView:self.view
          permittedArrowDirections:UIPopoverArrowDirectionRight
                          animated:YES];

credit to https://stackoverflow.com/a/19071958/1363779

Community
  • 1
  • 1
kevinl
  • 4,194
  • 6
  • 37
  • 55
0

The only one way which work properly in iOS7 is using of

-presentViewController:animated:completion:

You can try to change camera view transformation by cameraViewTransform property but result will be ugly. Adding of view to custom ViewController (which rotate to landscape) will give You ugly results too. I begin to hate this os version.

HereTrix
  • 1,315
  • 7
  • 13