I have loaded the zXing project into my own project. It loads fine, the zXing scanner pops up after a button call.
I can dismiss the view controller on thezxingControllerDidCancel but when I scan a QR code, no codes are ever recognised and therefore the didScanResult function never fires.
Does anyone have any idea about this one?
The didScanResult function is below.
-(void)zxingController:(ZXingWidgetController *)controller didScanResult:(NSString *)result{
resultLabel.text = result;
NSLog(@"did scan!!!");
[self dismissModalViewControllerAnimated:NO];
}
Note: I'm not sure if this is relevant, but when the scanner comes up, I get this logged by the app: "wait_fences: failed to receive reply: 10004003"
That tutorial does not mention that you must add a QRCodeReader
to the set of readers of your ZXingWidgetController
.
ZXingWidgetController
has a property called readers
, which is an NSSet
containing the instances of the readers (e.g. an instance of QRCodeReader
). Roughly, the readers' task is to analyze the images your camera takes and to extract the encoded information. Your ZXingWidgetController
has to know about the readers it should utilize, otherwise it has no chance to do anything meaningful. So you have to set the readers
property before you present the ZXingWidget.
The ZXing project has a sample app which demonstrates this. If you use ARC, then
ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO];
QRCodeReader* qRCodeReader = [[QRCodeReader alloc] init];
NSSet *readers = [[NSSet alloc] initWithObjects:qRCodeReader,nil];
widController.readers = readers;
[self presentModalViewController:widController animated:YES];
should do.
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