iosuiviewstoryboardavcam

Storyboard AVCam view resizing issues


I am not very good at using storyboard for iOS development. I have always been one to do most things from scratch. I am trying to use the AVCam that apple provides. I wanted to resize the previewView that has the AVFoundation objects for the camera, but whenever I resize it vertically to match the iOS camera, it scales proportionally horizontally as well.

How can i get it to shrink vertically only?

Thank in advance.


Solution

  • - (void)setSession:(AVCaptureSession *)session
    {
        ((AVPlayerLayer *)[self layer]).videoGravity = AVLayerVideoGravityResizeAspectFill;
        ((AVPlayerLayer *)[self layer]).bounds = ((AVPlayerLayer *)[self layer]).bounds;
        [(AVCaptureVideoPreviewLayer *)[self layer] setSession:session];
    }