I am trying to rotate a UIImage while capturing an image using the camera. However, I am getting the preview in portrait mode only. How do I display the preview image in landscape mode?
I am trying to rotate a UIImage while capturing an image using the camera.
Share
Reading the documentation for
UIImagePickerControllerreveals this interesting tidbit:Despite Apple’s warning, there is one way of doing things:
You can subscribe to rotation notifications in a delegate class:
Then, based on the current rotation of the device, you can apply a
CGAffineTransformto your overlay view. An example of this kind of transform can be found here. That particular answer will not help you in iOS 6, because theshouldAutorotateToInterfaceOrientationcalls will never be made to yourUIViewControllersubclass. Your best version strategy will be to subscribe to the notifications. Keep in mind that you’re going full manual here and your best bet is to figure out a way to only support portrait mode.Also, make sure to balance the notification calls with this call when finished: