可以在iOS8自定义键盘的后台打开AVCaptureVideoPreviewLayer吗? 我尝试使用此代码
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];
}
}
}
在键盘的背景中请求使用照相机但不打开照相机的许可。 请帮我。 感谢。