iPhone AVFoundation camera orientation

前端 未结 12 626
走了就别回头了
走了就别回头了 2020-12-02 09:46

I\'ve been tearing my hair out trying to get the AVFoundation camera to capture a picture in the correct orientation (i.e. the device orientation) but I can\'t get it to wor

12条回答
  •  星月不相逢
    2020-12-02 10:31

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

    The bit of code I was looking for is

    [UIDevice currentDevice].orientation;
    

    This goes in as so

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

    And it works perfectly :D

    Woop woop!

提交回复
热议问题