So - I have an app taking a picture with AVCaptureSession. I have an AVCapturePhoto - I want to end up with a uiImage in the correct orientation, which seems astonishingly hard to do. In portrait, I'm currently doing the following to correct the orientation:
UIImage toImage( AVCapturePhoto photo )
{
return new UIImage(photo.CGImageRepresentation, 1, UIImageOrientation.Right);
}
which works great - however, I can't find any way to detect if the phone is being held in landscape. Suppose for instance you have the orientation lock onto portrait - everything I query, such as the camera, the device current orientation - the UIApplication shared statusbarorientation, or whatever - returns portrait - but clearly the picture is actually turning up as a landscape image. I've looked at other answers, which say use "UIdevce.current.orientation" - but that always turns up "unknown" for me.
is there anyway of knowing the orientation of the camera, regardless of orientation lock, or otherwise turning up with a UIImage that is always the correct orientation - ie matches the real world?