Skip to content

Commit

Permalink
only add input to the session if there is an input
Browse files Browse the repository at this point in the history
This will prevent NSInvalidArgumentException on iOS8 in case the permission for
the camera was revoked in the settings.
  • Loading branch information
m0rk committed Jan 22, 2015
1 parent e461cd9 commit 2262a42
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Classes/NBNImageCaptureCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ - (void)setupImagePicker {
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error];
[captureSession addInput:input];

if (input) {
[captureSession addInput:input];
}

AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:captureSession];
captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
Expand Down

0 comments on commit 2262a42

Please sign in to comment.