public override void ViewWillTransitionToSize (CGSize toSize, IUIViewControllerTransitionCoordinator coordinator)
{
base.ViewWillTransitionToSize (toSize, coordinator);
var videoPreviewLayerConnection = PreviewView.VideoPreviewLayer.Connection;
if (videoPreviewLayerConnection != null) {
var deviceOrientation = UIDevice.CurrentDevice.Orientation;
AVCaptureVideoOrientation newVideoOrientation;
if (!TryConvertToVideoOrientation (deviceOrientation, out newVideoOrientation))
return;
if (!deviceOrientation.IsPortrait () && !deviceOrientation.IsLandscape ())
return;
videoPreviewLayerConnection.VideoOrientation = newVideoOrientation;
}
}