Fixes #8
This commit is contained in:
parent
b29198875d
commit
fdd947159e
|
@ -41,6 +41,7 @@
|
|||
{
|
||||
[super layoutSubviews];
|
||||
self.manager.previewLayer.frame = self.bounds;
|
||||
[self setBackgroundColor:[UIColor redColor]];
|
||||
[self.layer insertSublayer:self.manager.previewLayer atIndex:0];
|
||||
}
|
||||
|
||||
|
|
|
@ -62,17 +62,19 @@ RCT_EXPORT_VIEW_PROPERTY(orientation, NSInteger);
|
|||
}
|
||||
|
||||
AVCaptureDevice *captureDevice = [self deviceWithMediaType:AVMediaTypeVideo preferringPosition:self.presetCamera];
|
||||
AVCaptureDeviceInput *captureDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error];
|
||||
if (captureDevice != nil) {
|
||||
AVCaptureDeviceInput *captureDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error];
|
||||
|
||||
if (error)
|
||||
{
|
||||
NSLog(@"%@", error);
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
NSLog(@"%@", error);
|
||||
}
|
||||
|
||||
if ([self.session canAddInput:captureDeviceInput])
|
||||
{
|
||||
[self.session addInput:captureDeviceInput];
|
||||
self.captureDeviceInput = captureDeviceInput;
|
||||
if ([self.session canAddInput:captureDeviceInput])
|
||||
{
|
||||
[self.session addInput:captureDeviceInput];
|
||||
self.captureDeviceInput = captureDeviceInput;
|
||||
}
|
||||
}
|
||||
|
||||
AVCaptureStillImageOutput *stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
|
||||
|
@ -121,12 +123,17 @@ RCT_EXPORT_METHOD(changeCamera:(NSInteger)camera) {
|
|||
AVCaptureDevicePosition position = (AVCaptureDevicePosition)camera;
|
||||
AVCaptureDevice *captureDevice = [self deviceWithMediaType:AVMediaTypeVideo preferringPosition:(AVCaptureDevicePosition)position];
|
||||
|
||||
if (captureDevice == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSError *error = nil;
|
||||
AVCaptureDeviceInput *captureDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error];
|
||||
|
||||
if (error)
|
||||
{
|
||||
NSLog(@"%@", error);
|
||||
return;
|
||||
}
|
||||
|
||||
[self.session beginConfiguration];
|
||||
|
|
|
@ -7,7 +7,7 @@ A camera viewport for React Native. This module is currently in the very early s
|
|||
## Known Issues
|
||||
Below is a list of known issues. Pull requests are welcome for any of these issues!
|
||||
|
||||
- [Camera module may cause app to crash in simulator](https://github.com/lwansbrough/react-native-camera/issues/8)
|
||||
- Orientation is not set correctly upon device rotation
|
||||
|
||||
## Getting started
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"type" : "git",
|
||||
"url" : "https://github.com/lwansbrough/react-native-camera.git"
|
||||
},
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"description": "A Camera component for React Native. Also reads barcodes.",
|
||||
"main": "Camera.ios.js",
|
||||
"author": "Lochlan Wansbrough <lochie@live.com> (http://lwansbrough.com)",
|
||||
|
|
Loading…
Reference in New Issue