I'm trying to make a QR Code reader. I have a view that has autoresizing for both directions. It goes ok when I try the simulator with the same screen size but when I try it with a bigger screen, the camera doesn't fill the view.
.h file:
@property (strong, nonatomic) IBOutlet UIView *livevideo;
.m file:
output.rectOfInterest = self.livevideo.bounds;
AVCaptureVideoPreviewLayer *newCaptureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
CGRect bounds=_livevideo.layer.bounds;
newCaptureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
newCaptureVideoPreviewLayer.bounds=bounds;
newCaptureVideoPreviewLayer.position=CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
[self.livevideo.layer addSublayer:newCaptureVideoPreviewLayer];
0 comments:
Post a Comment