捕获照片时UIImagePickerController的有线行为 [英] Wired behaviour of UIImagePickerController while capturing photo

查看:106
本文介绍了捕获照片时UIImagePickerController的有线行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的整个应用是纵向的,只有相机视图应以横向打开.

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

我参考了Apple的示例代码UIImagePickerController https://developer.apple.com/library/ios/samplecode/PhotoPicker/PhotoPicker.zip

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

根据我的要求,我必须强制UIImagePickerController以横向模式启动相机,并且需要捕获照片.

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

我知道这一点,

UIImagePickerController类仅支持纵向模式.这 类旨在按原样使用,不支持子类化. 此类的视图层次结构是私有的,不能修改, 除了一个例外.您可以将自定义视图分配给 cameraOverlayView属性,并使用该视图显示其他内容 信息或管理摄像头界面之间的交互 和您的代码.

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. 具有UIImagePickerController的子类,我在其中实现了所有必需的定向方法.这样, https://stackoverflow.com/a/14618870/1603234
  2. 另一种方法:将UIImagePickerController的类别设置为与我展示相机相同的类.

  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

但这无济于事.

请参见下面的屏幕截图

这是使用真实相机拍摄的正确照片(iPhone4s相机应用程序)

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

这是从应用程序的相机中捕获的.相机视图向侧面旋转.

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

  • 我要纠正的是,为UIImagePickerController

有没有一种方法可以强制视图以横向模式捕获照片?

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

为什么相机向内旋转?

使用cameraOverlayView可以实现吗?

推荐答案

您不能修改图像选择器的行为,如Apple所述.

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

如果您需要的功能超出了UIImagePickerController所提供的功能,则可以使用 AV Foundation 框架来捕获图像.

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

Apple有一个示例应用程序,该示例程序演示了使用AV Foundation.

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

这篇关于捕获照片时UIImagePickerController的有线行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆