AVCaptureMetadataOutput setMetadataObjectTypes unsupported type found
I know someone asked this question. But I wish I could find an answer.
dispatchQueue = dispatch_queue_create("myQueue", NULL);
[captureMetadaOutput setMetadataObjectsDelegate:self queue:dispatchQueue];
// [captureMetadaOutput setMetadataObjectTypes:[NSArray arrayWithObject:AVMetadataObjectTypeQRCode]];
// 设置条码类型
captureMetadaOutput.metadataObjectTypes = @[AVMetadataObjectTypeQRCode];
I got crash information from Crashlytics:
[AVCaptureMetadataOutput setMetadataObjectTypes:] - unsupported type found. Use -availableMetadataObjectTypes.
+3
Huichuang Xuanyuan
source
to share
3 answers
We must first add the output to the session and then install metadataObjectTypes
.
+5
Alan luo
source
to share
This is because you are closing the resolution of the camera. You can open your camera's authorization and then open the canner to scan the QRCode. Strike gives 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];
}
+1
Whyte.Lee
source
to share
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];
}
+1
brownfeng
source
to share