简体   繁体   English

具有UIImagePickerControllerSourceTypeCamera方向问题的UIImagePickerViewController

[英]UIImagePickerViewController with UIImagePickerControllerSourceTypeCamera orientation issue

Just interested, if anyone has any sample code, using the UIImagePicker for a cameraview in fullscreen with landscape/portrait rotations. 只要有兴趣,如果有人有任何示例代码,就可以使用UIImagePicker在具有横向/纵向旋转的全屏模式下进行摄影机查看。

Instead of 代替

[self presentModalViewController:imagePicker animated:NO];

I'm adding the imagepicker.view as a sub View like so: 我将imagepicker.view添加为子视图,如下所示:

[cameraView addSubview: imagePicker.view];

The problem is, when this happens, the frame of the imagePicker.view is being added with a 90 degrees rotation. 问题是,发生这种情况时,imagePicker.view的帧将旋转90度添加。 Which would be fine to perform an affine Translation, except doing so changes the rotation of the actual Camera feed. 这可以执行仿射平移,除非这样做会更改实际“相机” Feed的旋转。

Doing something like, works fine, 做类似的事情,效果很好,

[imagePicker.view setFrame: CGRectMake(0, 0, 480, 320)];

until the user rotates. 直到用户旋转为止。

I can listen for the rotate notification with this: 我可以这样听轮播通知:

- (void) didRotate:(NSNotification *)notification

But applying a Affine Translation, is ruining the camera overlay and it's subviews. 但是,应用仿射翻译会破坏摄影机叠加层及其子视图。

The outcome was that using the UIImagePicker for the modal camera popup isn't appropriate for more than basic AVCamera usage. 结果是,将UIImagePicker用于模态相机弹出窗口不仅仅适用于基本的AVCamera使用。 I still used it for picking existing photos, but ended up using the sample code 我仍然使用它来拾取现有照片,但最终使用了示例代码

My main VC header keeps: 我的主要VC标头保留:

UIImagePickerController *_imagePicker;
AVCameraView *avCameraView;

AVCameraView retains: AVCameraView保留:

@property (retain) CaptureSessionManager *captureManager;

Which is used to take photos as well as swap between the front/back camera if the device is a 4+ https://github.com/mrdavenz/CaptureSessionManager 如果设备为4+ https://github.com/mrdavenz/CaptureSessionManager,则用于拍照以及在前后摄像头之间切换

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM