From b1daed1e61d73c57502b720fb20ff9a6feacc52b Mon Sep 17 00:00:00 2001 From: Lochlan Wansbrough Date: Mon, 20 Jul 2015 16:49:41 -0700 Subject: [PATCH] Fixes #71 --- RCTCameraManager.m | 10 +++++++++- package.json | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/RCTCameraManager.m b/RCTCameraManager.m index b939505..a7302ff 100644 --- a/RCTCameraManager.m +++ b/RCTCameraManager.m @@ -213,7 +213,13 @@ RCT_EXPORT_METHOD(stopCapture) { } } +- (BOOL)isSimulator { + return [[[UIDevice currentDevice].model lowercaseString] rangeOfString:@"simulator"].location != NSNotFound; +} + - (void)startSession { + if ([self isSimulator]) return; + dispatch_async(self.sessionQueue, ^{ if (self.presetCamera == AVCaptureDevicePositionUnspecified) { self.presetCamera = AVCaptureDevicePositionBack; @@ -256,6 +262,8 @@ RCT_EXPORT_METHOD(stopCapture) { } - (void)stopSession { + if ([self isSimulator]) return; + dispatch_async(self.sessionQueue, ^{ [self.previewLayer removeFromSuperlayer]; [self.session stopRunning]; @@ -321,7 +329,7 @@ RCT_EXPORT_METHOD(stopCapture) { - (void)captureStill:(NSInteger)target options:(NSDictionary *)options callback:(RCTResponseSenderBlock)callback { dispatch_async(self.sessionQueue, ^{ - if ([[[UIDevice currentDevice].model lowercaseString] rangeOfString:@"simulator"].location != NSNotFound){ + if ([self isSimulator]){ CGSize size = CGSizeMake(720, 1280); UIGraphicsBeginImageContextWithOptions(size, YES, 0); diff --git a/package.json b/package.json index bf6c117..ecc4aa9 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type" : "git", "url" : "https://github.com/lwansbrough/react-native-camera.git" }, - "version": "0.3.2", + "version": "0.3.3", "description": "A Camera component for React Native. Also reads barcodes.", "main": "Camera.ios.js", "author": "Lochlan Wansbrough (http://lwansbrough.com)",