I tried all the answers described here, but none of them offered the result I was looking for. Eiter the whole UIImagePickerViewController was converted, so the camera was not intuitive, not like looking in the mirror, or only the image was converted afterwards, which was fine, but you have the wrong image viewing between them. So I ended up with this hack, it is definitely not the best, but it works on iOS8 and 9 and gives me the result I need.
Make sure you add an observer to receive a notification when you click the image capture button:
NSNotificationCenter.defaultCenter().addObserver(self, selector: "photoTaken", name: "_UIImagePickerControllerUserDidCaptureItem", object: nil)
In the potoTaken method potoTaken you can do something like this to find the preview image and convert it the way you expect:
func photoTaken() { for subview in self.imagePicker.view.subviews { for subsubview in subview.subviews { for subsubsubview in subsubview.subviews { for subsubsubsubview in subsubsubview.subviews { for subsubsubsubsubview in subsubsubsubview.subviews { for subsubsubsubsubsubview in subsubsubsubsubview.subviews { for subsubsubsubsubsubsubview in subsubsubsubsubsubview.subviews { if subsubsubsubsubsubsubview.isKindOfClass(UIImageView) { subsubsubsubsubsubsubview.transform = CGAffineTransformScale(self.imagePicker.cameraViewTransform, -1, 1) } } } } } } } } }
And in your delegate didFinishPickingMediaWithInfo , flip the image again before saving or displaying.
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) { if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage { let flippedImage = UIImage(CGImage: pickedImage.CGImage!, scale: pickedImage.scale, orientation: .LeftMirrored) myCustomPhotoAlbum.sharedInstance.saveImage(flippedImage) self.imageView.image = flippedImage } self.dismissViewControllerAnimated(true, completion: nil) }
fruechtemuesli Jan 25 '16 at 13:07 on 2016-01-25 13:07
source share