From 2eac22d151875f55860e641dafef537bcb75af0e Mon Sep 17 00:00:00 2001 From: Kyle Corbitt Date: Sat, 2 Apr 2016 15:16:15 -0700 Subject: [PATCH] init preview each time view requested --- ios/RCTCameraManager.m | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/ios/RCTCameraManager.m b/ios/RCTCameraManager.m index ed295b8..d8861fb 100644 --- a/ios/RCTCameraManager.m +++ b/ios/RCTCameraManager.m @@ -22,7 +22,12 @@ RCT_EXPORT_MODULE(); - (UIView *)view { - return [[RCTCamera alloc] initWithManager:self bridge:self.bridge]; + self.session = [AVCaptureSession new]; + + self.previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:self.session]; + self.previewLayer.needsDisplayOnBoundsChange = YES; + + return [[RCTCamera alloc] initWithManager:self bridge:self.bridge]; } RCT_EXPORT_VIEW_PROPERTY(aspect, NSInteger); @@ -142,18 +147,10 @@ RCT_EXPORT_VIEW_PROPERTY(onZoomChanged, BOOL) } - (id)init { - if ((self = [super init])) { self.mirrorImage = false; - self.session = [AVCaptureSession new]; - - self.previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:self.session]; - self.previewLayer.needsDisplayOnBoundsChange = YES; - self.sessionQueue = dispatch_queue_create("cameraManagerQueue", DISPATCH_QUEUE_SERIAL); - - } return self; }