mirror of
https://github.com/status-im/react-native-camera.git
synced 2025-02-23 17:28:08 +00:00
Merge pull request #82 from datwelk/bugfix/xcode7-simulator
Use proper check to see if running on simulator
This commit is contained in:
commit
914c0e3c9d
@ -213,13 +213,11 @@ RCT_EXPORT_METHOD(stopCapture) {
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isSimulator {
|
||||
return [[[UIDevice currentDevice].model lowercaseString] rangeOfString:@"simulator"].location != NSNotFound;
|
||||
}
|
||||
|
||||
- (void)startSession {
|
||||
if ([self isSimulator]) return;
|
||||
|
||||
#if TARGET_IPHONE_SIMULATOR
|
||||
return;
|
||||
#endif
|
||||
|
||||
dispatch_async(self.sessionQueue, ^{
|
||||
if (self.presetCamera == AVCaptureDevicePositionUnspecified) {
|
||||
self.presetCamera = AVCaptureDevicePositionBack;
|
||||
@ -262,8 +260,10 @@ RCT_EXPORT_METHOD(stopCapture) {
|
||||
}
|
||||
|
||||
- (void)stopSession {
|
||||
if ([self isSimulator]) return;
|
||||
|
||||
#if TARGET_IPHONE_SIMULATOR
|
||||
return;
|
||||
#endif
|
||||
|
||||
dispatch_async(self.sessionQueue, ^{
|
||||
[self.previewLayer removeFromSuperlayer];
|
||||
[self.session stopRunning];
|
||||
@ -329,8 +329,7 @@ RCT_EXPORT_METHOD(stopCapture) {
|
||||
|
||||
- (void)captureStill:(NSInteger)target options:(NSDictionary *)options callback:(RCTResponseSenderBlock)callback {
|
||||
dispatch_async(self.sessionQueue, ^{
|
||||
if ([self isSimulator]){
|
||||
|
||||
#if TARGET_IPHONE_SIMULATOR
|
||||
CGSize size = CGSizeMake(720, 1280);
|
||||
UIGraphicsBeginImageContextWithOptions(size, YES, 0);
|
||||
[[UIColor whiteColor] setFill];
|
||||
@ -340,9 +339,7 @@ RCT_EXPORT_METHOD(stopCapture) {
|
||||
|
||||
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
|
||||
[self saveImage:imageData target:target metadata:nil callback:callback];
|
||||
|
||||
} else {
|
||||
|
||||
#else
|
||||
[[self.stillImageOutput connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:self.previewLayer.connection.videoOrientation];
|
||||
|
||||
[self.stillImageOutput captureStillImageAsynchronouslyFromConnection:[self.stillImageOutput connectionWithMediaType:AVMediaTypeVideo] completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
|
||||
@ -406,7 +403,7 @@ RCT_EXPORT_METHOD(stopCapture) {
|
||||
callback(@[RCTMakeError(error.description, nil, nil)]);
|
||||
}
|
||||
}];
|
||||
}
|
||||
#endif
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user