Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Commit

Permalink
Fixes #8
Browse files Browse the repository at this point in the history
  • Loading branch information
lwansbrough committed Apr 24, 2015
1 parent b291988 commit fdd9471
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
1 change: 1 addition & 0 deletions RCTCamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ - (void)layoutSubviews
{
[super layoutSubviews];
self.manager.previewLayer.frame = self.bounds;
[self setBackgroundColor:[UIColor redColor]];
[self.layer insertSublayer:self.manager.previewLayer atIndex:0];
}

Expand Down
29 changes: 18 additions & 11 deletions RCTCameraManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,19 @@ - (id)init {
}

AVCaptureDevice *captureDevice = [self deviceWithMediaType:AVMediaTypeVideo preferringPosition:self.presetCamera];
AVCaptureDeviceInput *captureDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error];

if (error)
{
NSLog(@"%@", error);
}

if ([self.session canAddInput:captureDeviceInput])
{
[self.session addInput:captureDeviceInput];
self.captureDeviceInput = captureDeviceInput;
if (captureDevice != nil) {
AVCaptureDeviceInput *captureDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error];

if (error)
{
NSLog(@"%@", error);
}

if ([self.session canAddInput:captureDeviceInput])
{
[self.session addInput:captureDeviceInput];
self.captureDeviceInput = captureDeviceInput;
}
}

AVCaptureStillImageOutput *stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
Expand Down Expand Up @@ -121,12 +123,17 @@ - (id)init {
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];
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down

0 comments on commit fdd9471

Please sign in to comment.