且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iPhone AVFoundation 相机方向

更新时间:2023-02-02 14:55:16

好吧,这让我永远水力压裂,但我做到了!

Well, it's taken me fracking forever but I've done it!

我正在寻找的代码是

[UIDevice currentDevice].orientation;

这样就可以了

AVCaptureConnection *videoConnection = [CameraVC connectionWithMediaType:AVMediaTypeVideo fromConnections:[imageCaptureOutput connections]];
if ([videoConnection isVideoOrientationSupported])
{
    [videoConnection setVideoOrientation:[UIDevice currentDevice].orientation];
}

而且效果很好:D

呜呜呜!