iPhone - Mirroring back a picture taken from the front camera

前端 未结 8 2048
半阙折子戏
半阙折子戏 2020-12-24 04:06

When using the front camera of the iPhone 4 to take a picture, the taken picture is mirrored compared with what you see on the iPhone screen. How may I restore the \"on scre

相关标签:
8条回答
  • 2020-12-24 04:32

    I'd like to vote up @Lucas Eduardo , I have tried to integrate the component LEImagePickerController into my project as below:

    - (void)onCamera:(id)sender {
        UIImagePickerController* imagePicker = [[UIImagePickerController alloc] init];
        imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
        imagePicker.delegate = self;
    
        //cover the switch button at the top right corner, I just need user take photo with the front facing camera
        UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
        view.center = CGPointMake(CGRectGetWidth(imagePicker.view.bounds) - CGRectGetWidth(view.bounds)/2, CGRectGetHeight(view.bounds)/2);
        view.backgroundColor = [UIColor blackColor];
        [imagePicker.view addSubview:view];
    
        LEMirroredImagePicker* mirrorFrontPicker = [[LEMirroredImagePicker alloc] initWithImagePicker:imagePicker];
        [mirrorFrontPicker mirrorFrontCamera];
    
        [self presentViewController:imagePicker animated:YES completion:nil];
    }
    
    0 讨论(0)
  • 2020-12-24 04:33

    As the other answers, I had the same problem. But just flip the final image is only half the answer, because the preview image, displayed by the UIPickerController when you take a picture with the front camera, it's still inverted (mirrored).

    Based in some codes from internet, I created a Pod to get this wanted behavior:

    https://github.com/lucasecf/LEMirroredImagePicker

    After installed, you just have to call this two lines of code together with your UIImagePickerController:

    self.mirrorFrontPicker = [[LEMirroredImagePicker alloc] initWithImagePicker:pickerController];
    [self.mirrorFrontPicker mirrorFrontCamera];
    

    And thats it, simply as that. You can check for more informations in the README of the github link.

    0 讨论(0)
提交回复
热议问题