QRCodeReaderViewController
QRCodeReaderViewController copied to clipboard
_metadataObjectTypes is staying nil and crash app.
Yannick,
I has one problem and make some adjusts (workaround). Please, see.
The _metadataObjectTypes is always nil. QRCodeReader.m
- (id)init
{
if ((self = [super init])) {
_metadataObjectTypes = @[AVMetadataObjectTypeQRCode]; //not work. _metadataObjectTypes will continue nil
[self setupAVComponents];
[self configureDefaultComponents];
}
return self;
}
- (id)initWithMetadataObjectTypes:(NSArray *)metadataObjectTypes
{
if ((self = [super init])) {
self.metadataObjectTypes = metadataObjectTypes; //not work. _metadataObjectTypes will continue nil.
[self setupAVComponents];
[self configureDefaultComponents];
}
return self;
}
Workaround: QRCodeReader.m
@interface QRCodeReader () <AVCaptureMetadataOutputObjectsDelegate>
@property (strong, nonatomic) AVCaptureDevice *defaultDevice;
@property (strong, nonatomic) AVCaptureDeviceInput *defaultDeviceInput;
@property (strong, nonatomic) AVCaptureDevice *frontDevice;
@property (strong, nonatomic) AVCaptureDeviceInput *frontDeviceInput;
@property (strong, nonatomic) AVCaptureMetadataOutput *metadataOutput;
@property (strong, nonatomic) AVCaptureSession *session;
@property (strong, nonatomic) AVCaptureVideoPreviewLayer *previewLayer;
@property (strong, nonatomic) NSArray *metadataObjectTypes; //ADDED
And replace all _ metadataObjectTypes for self. metadataObjectTypes in QRCodeReader.m.
Now it works!
@humbertosales Thank you for the hint. I'll investigate that when I'll have some time.