iOS 7 AVCaptureMetadataOutput delegate (QRCode scanner)

后端 未结 2 465
青春惊慌失措
青春惊慌失措 2021-01-30 15:19

I\'m trying to implement a QRCode scanner with the new iOS 7 features but my code isn\'t calling the main AVCaptureMetadataOutputObjectsDelegate method.

I\'

2条回答
  •  日久生厌
    2021-01-30 15:50

    I am trying to figure this out myself. The documentation seems to say that if you don't set the type(s) you want in metadataObjectTypes, you won't get any calls. But my iPad Mini's back camera returns an empty array for availableMetadataObjectTypes. Let us know what you figure out.

    Edit:

    I just figured out that if you add the AVCaptureMetadataOutput object to the session, the availableMetadataObjectTypes gets filled in and you can add the barcode detector to it. Then the captureOutput delegate will get called, so like this:

    AVCaptureMetadataOutput *output = [[AVCaptureMetadataOutput alloc] init];
    [output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
    [session addOutput:output];
    output.metadataObjectTypes = @[AVMetadataObjectTypeQRCode];
    

提交回复
热议问题