Front facing camera in UIImagePickerController

后端 未结 9 1242
暗喜
暗喜 2020-12-02 06:42

I am developing the front facing camera app in iPad2 by using the UIImagePickerController.

When I capture the image it\'s shows as flipped from left to

9条回答
  •  心在旅途
    2020-12-02 07:33

    Just to add how I have just achieved this without subclassing UIImagePickerController and without adding extra buttons to the camera view.

    Simply listen for this notification which is fired several times whenever the camera is changed:

    [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(cameraChanged:)
                                                     name:@"AVCaptureDeviceDidStartRunningNotification"
                                                   object:nil];
    

    Then use this method to flip the camera view:

    - (void)cameraChanged:(NSNotification *)notification
    {
        if(imagePicker.cameraDevice == UIImagePickerControllerCameraDeviceFront)
        {
            imagePicker.cameraViewTransform = CGAffineTransformIdentity;
            imagePicker.cameraViewTransform = CGAffineTransformScale(imagePicker.cameraViewTransform, -1,     1);
        } else {
            imagePicker.cameraViewTransform = CGAffineTransformIdentity;
        }
    }
    

提交回复
热议问题