AVCaptureVideoPreviewLayer does not change when parent layer is resized

I am using AVFoundation for the camera. Here I am adding the AVCaptureVideoPreviewLayer to the container view (0,0786,1024). When I rotate from portrait to landscape, the preview layer does not resize to save.

Note. I am using Autostart for my application. The application was created for iOS7.0

Below is the code to add the previe layer to the container.

- (void)addPreviewLayeInView:(UIView *)aView
    if (!session) return;
    effectiveScale = 1.0;
    preview = [AVCaptureVideoPreviewLayer layerWithSession:session];
    preview.frame = aView.bounds;
    preview.videoGravity = AVLayerVideoGravityResizeAspectFill;
    preview.backgroundColor = [[UIColor redColor] CGColor];
    [aView.layer addSublayer:preview];


Any help could be appreciated.


source to share

All Articles