8

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"

  • Could you post how you create and show the ZXingWidgetController? – Aaron Wojnowski Sep 08 '12 at 15:16
  • Basically I ran through this tutorial on adding it to my project (http://yannickloriot.com/2011/04/how-to-install-zxing-in-xcode-4/) So I imported them into my viewcontrollers .h file Used the 'didScanResult' and 'zxingControllerDidCancel' functions of the ZXingDelegate. zxingControllerDidCancel works perfectly as previously stated. Does this help? – Scott McConnell Sep 08 '12 at 22:42
  • Look at [this question](http://stackoverflow.com/questions/1371346/wait-fences-failed-to-receive-reply-10004003) to solve the 10004003 Error. – Daniel Sep 25 '12 at 11:43
  • 1
    That tutorial does not mention that you must add a QRCodeReader to the set of readers of your ZXingWidgetController. – ilmiacs Sep 26 '12 at 14:08
  • @ilmiacs Thanks for that. But what exactly does that mean? – Scott McConnell Sep 27 '12 at 01:20

1 Answers1

4

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.

ilmiacs
  • 2,566
  • 15
  • 20