Wired behaviour of UIImagePickerController while capturing photo

人盡茶涼 提交于 2019-12-11 18:59:06

问题


My entire app is in portrait orientation, only camera view should open in landscape orientation.

I've taking reference of Apple's sample code of UIImagePickerController, https://developer.apple.com/library/ios/samplecode/PhotoPicker/PhotoPicker.zip

In my requirement, I've to force UIImagePickerController to start camera in landscape mode, and need to capture the photos.

I'm aware of this,

The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified, with one exception. You can assign a custom view to the cameraOverlayView property and use that view to present additional information or manage the interactions between the camera interface and your code.

I've implemented following way to achieve this,

  1. sub class with UIImagePickerController and where I implemented all required orientation methods. like this, https://stackoverflow.com/a/14618870/1603234
  2. another method : make a category for UIImagePickerController into same class where I am presenting the camera.

    @implementation UIImagePickerController(rotationFixed)
    
    - (BOOL) shouldAutorotate {
        return NO;
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
       return UIInterfaceOrientationLandscapeRight;
    }
    
    - (NSUInteger)supportedInterfaceOrientations{
       return UIInterfaceOrientationMaskLandscape;
    }
    @end
    

but this wont help.

See the screenshots below,

This is correct photo, taken with real camera (iPhone4s camera app)

This is captured within camera from app. Camera view was rotated in side.

  • What I've to correct is, to make correct view for camera of UIImagePickerController

  • Is there a way that I can force a view to capture photos in landscape mode?

  • Why camera rotated inside?

  • With cameraOverlayView can I achieve this?


回答1:


You cannot modify the behavior of the image picker, as documented by Apple.

If you need more functionality than provided by the UIImagePickerController, you can use AV Foundation framework to capture the images.

Apple has a sample application that demonstrates the use of AV Foundation.



来源:https://stackoverflow.com/questions/24409530/wired-behaviour-of-uiimagepickercontroller-while-capturing-photo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!