I used ios7 API to scan QRcode , code as bellow:
    AVCaptureMetadataOutput *output = [[AVCaptureMetadataOutput alloc] init];
    [self.captureSession addOutput:output];
    [output setMetadataObjectsDelegate:self queue:captureOutputBufferQueue];
    output.metadataObjectTypes = @[AVMetadataObjectTypeQRCode];
I got crashes info from Crashlytics:
  NSInvalidArgumentException
  *** -[AVCaptureMetadataOutput setMetadataObjectTypes:] - unsupported type found. Use -     availableMetadataObjectTypes.
 Thread : Fatal Exception: NSInvalidArgumentException
 0  CoreFoundation                 0x303b9f83 __exceptionPreprocess + 130
 1  libobjc.A.dylib                0x3ab6accf objc_exception_throw + 38
 2  AVFoundation                   0x2f2f7c29 -[AVCaptureMetadataOutput rectOfInterest]
anyone had met this?
You must add the output to session before set the metadataObjectTypes. I meet the error, and use the following code fix it.
@property (nonatomic, strong) AVCaptureMetadataOutput *output;
@property (nonatomic, strong) AVCaptureSession *session; 
- (AVCaptureMetadataOutput *)output
{
   if (!_output) {
       _output = [[AVCaptureMetadataOutput alloc] init];
       [_output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
   }
   return _output;
}
- (AVCaptureSession *)session
{
  if (!_session) {
       _session = [[AVCaptureSession alloc] init];
       [_session setSessionPreset:AVCaptureSessionPresetHigh];
       if ([_session canAddInput:self.input]) {
           [_session addInput:self.input];
       }
       if ([_session canAddOutput:self.output]) {
           [_session addOutput:self.output];
           NSArray *typeList = self.output.availableMetadataObjectTypes;
           NSLog(@"availableMetadataObjectTypes : %@", typeList);
           self.output.metadataObjectTypes = @[AVMetadataObjectTypeQRCode];
       }
   }
   return _session;
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With