AVCaptureMetadataOutput setMetadataObjectTypes unsupported type found

后端 未结 4 1346
不知归路
不知归路 2021-01-17 22:57

I know there are someone have ask this question.But it is a sorry i donot find the answer.

dispatchQueue = dispatch_queue_create(\"myQueue\", NULL);
[capture         


        
相关标签:
4条回答
  • 2021-01-17 23:18

    It is also possible that the user’s camera is broken. You still need to do:

    if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear]){
        //...
    }
    
    0 讨论(0)
  • 2021-01-17 23:22

    It is because of you close the camera authorization. You can open your camera authorization, then open canner to scan QRCode. The blow give typical examples:

    AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; 
    if(status == AVAuthorizationStatusAuthorized) {  
        // authorized  
        [self setupCamera];  
    } else {  
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Tips" message:@"Authorization is required to use the camera, please check your permission settings: Settings> Privacy> Camera" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok", nil];
            [alert show];  
    }
    
    0 讨论(0)
  • 2021-01-17 23:31

    you need to do like this:

            if ([_captureSession canAddOutput:self.metadataOutput]) {
            [_captureSession addOutput:self.metadataOutput];
            // 这里注意,必须先将metadataOutput 加入到session,然后才能设置metadataObjectTypes,注意顺序,不然会crash
            self.metadataOutput.metadataObjectTypes = @[AVMetadataObjectTypeQRCode];
            [self.metadataOutput setMetadataObjectsDelegate:self queue:_videoDataOutputQueue];
        }
    
    0 讨论(0)
  • 2021-01-17 23:36

    We have to add the output to session first, and then we can set the metadataObjectTypes.

    0 讨论(0)
提交回复
热议问题