AVCam not in fullscreen

雨燕双飞 提交于 2019-12-21 04:27:21

问题


I've integrated AVCam in my iOS app. The problem is in iPhone 4 the preview frame isn't fullscreen, it has empty side borders...

How can I solve this?

Thanks.


回答1:


You need to use the videoGravity property of the AVCaptureVideoPreviewLayer.

Take a look to the doc. You need to use: AVLayerVideoGravityResizeAspectFill

Edit:

Based on that the solution founded by the asker is:

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



回答2:


Fixed it with the following method in AVCamPreviewView.

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


来源:https://stackoverflow.com/questions/20497575/avcam-not-in-fullscreen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!