1. 程式人生 > >iOS做自定義拍照的時候影象選擇90度,為了契合iPad的拍照

iOS做自定義拍照的時候影象選擇90度,為了契合iPad的拍照

可以通過獲取AVCaptureConnection,然後呼叫setVideoOrientation:方法解決影象90°問題。

比如:顯示AVCaptureVideoPreviewLayer

[[_videoPreviewLayer
 connection] 
setVideoOrientation:AVCaptureVideoOrientationLandscapeRight];
拍照,輸出用AVCaptureStillImageOutput時,
outputPic
 = [[AVCaptureStillImageOutput alloc]init];
AVCaptureConnection
 * videoConnection = [outputPic connectionWithMediaType:AVMediaTypeVideo];
[videoConnection
setVideoOrientation:AVCaptureVideoOrientationLandscapeRight];
攝像,輸出用AVCaptureMovieFileOutput時,
outputMovie
 = [[AVCaptureMovieFileOutput alloc] init]; 
AVCaptureConnection
 * videoConnection = [outputMovie connectionWithMediaType:AVMediaTypeVideo];

[videoConnection
setVideoOrientation:AVCaptureVideoOrientationLandscapeRight];


檢視原文:https://www.liuandy.cn/ios/2018/01/19/2281.html