When using the UIImagePickerController
, some of you must have noticed that, by default, the photo taken by the front camera is mirrored.
And even if you just invert the image taken in the delegate, the image displayed as preview by the UIImagePickerController
will be still mirrored, resulting in a odd experience by the user.
See the example of UIImagePickerController's default front camera photo below:
And now used together with the LEMirroredImagePicker:
Drag and copy the two files in the LEMirroredImagePicker folder into your project, or add it as a git submodule.
LEMirroredImagePicker
is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod "LEMirroredImagePicker"
LEMirroredImagePicker
is ridiculously easy to use. All you need to do is invoke the two lines of code below:
#import "LEMirroredImagePicker.h"
(..)
@property(nonatomic) LEMirroredImagePicker *mirrorFrontPicker;
(..)
self.mirrorFrontPicker = [[LEMirroredImagePicker alloc] initWithImagePicker:pickerController];
[self.mirrorFrontPicker mirrorFrontCamera];
(..)
And thats it. Now the images taken by the front camera shown in the preview will be equal the ones the saw in the camera. See a complete example, with the UIImagePickerController
, below:
UIImagePickerController *pickerController = [UIImagePickerController new];
pickerController.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
pickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront;
}
else
{
pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
self.mirrorFrontPicker = [[LEMirroredImagePicker alloc] initWithImagePicker:pickerController];
[self.mirrorFrontPicker mirrorFrontCamera];
[self presentViewController:pickerController animated:YES completion:nil];
Liked the project? Is there something missing or that could be better? Feel free to contribute :)
-
Fork it
-
Create your branch
git checkout -b name-your-feature
-
Commit it
git commit -m 'the difference'
-
Push it
git push origin name-your-feature
-
Create a Pull Request
Lucas Eduardo, [email protected]
LEMirroredImagePicker is available under the MIT license. See the LICENSE file for more info.