- (void)setupScanningSession {
// Initalising hte Capture session before doing any video capture/scanning.
NSError *error;
self.captureSession = [[AVCaptureSession alloc] init];
self.captureSession.sessionPreset = AVCaptureSessionPresetMedium;
// Set camera capture device to default and the media type to video.
AVCaptureDevice *captureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
// Set video capture input: If there a problem initialising the camera, it will give am error.
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error];
if (!input) {
NSLog(@"Error connecting camera: %@", [error localizedDescription]);
return;
}
// Adding input souce for capture session. i.e., Camera
[self.captureSession addInput:input];
captureDevice всегда равен nil , когда я пытаюсь запустить приложение на реальном устройстве. IPad представляет собой A1474 с iOS 12.
Тот же кусок кода отлично работает на моем iPhone 8.