我正在使用AVFoundation类在我的应用程序中实现自定义相机.我只捕捉静止图像,而不是视频.我有一切工作,但我被一些东西困扰.我会在捕获静止图像时考虑设备方向,并适当地设置视频连接的videoOrientation.代码段:
// set the videoOrientation based on the device orientation to
// ensure the pic is right side up for all orientations
AVCaptureVideoOrientation videoOrientation;
switch ([UIDevice currentDevice].orientation) {
case UIDeviceOrientationLandscapeLeft:
// Not clear why but the landscape orientations are reversed
// if I use AVCaptureVideoOrientationLandscapeLeft here the pic ends up upside down
videoOrientation = AVCaptureVideoOrientationLandscapeRight;
break;
case UIDeviceOrientationLandscapeRight:
// Not clear why but the landscape orientations are reversed
// if I use AVCaptureVideoOrientationLandscapeRight here the pic ends up upside down …Run Code Online (Sandbox Code Playgroud)