简体   繁体   中英

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.

Instead of

[self presentModalViewController:imagePicker animated:NO];

I'm adding the imagepicker.view as a sub View like so:

[cameraView addSubview: imagePicker.view];

The problem is, when this happens, the frame of the imagePicker.view is being added with a 90 degrees rotation. Which would be fine to perform an affine Translation, except doing so changes the rotation of the actual Camera 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. I still used it for picking existing photos, but ended up using the sample code

My main VC header keeps:

UIImagePickerController *_imagePicker;
AVCameraView *avCameraView;

AVCameraView retains:

@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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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