IOS8: custom keyboard - open camera with AVCaptureVideoPreviewLayer on keyboard background
Is it possible to open AVCaptureVideoPreviewLayer in front of an iOS8 custom keyboard? I tried with this code
AVCaptureSession *session = [[AVCaptureSession alloc] init];
AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if (videoDevice)
{
NSError *error;
AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
if (!error)
{
if ([session canAddInput:videoInput])
{
[session addInput:videoInput];
AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:session];
previewLayer.frame = self.bounds;
NSLog(@"open %@",NSStringFromCGRect(self.bounds));
[self.camView.layer addSublayer:previewLayer];
[session startRunning];
}
}
}
It asks for permission to use the camera, but not open the camera in the background of the keyboard. Please help me. Thank.
+3
source to share
No one has answered this question yet
Check out similar questions: