Trying to use ZBar to capture a barcode. I have the following code in place at the moment. The scanner shows, and appears to scan the barcode as the green overlay appears around the code. I don't know how to capture the decoded results.
I'm probably going about it wrong, so thought I'd ask. Nothing is output to the console when scanning, so don't think the didReadSymbols is being called at all.
.h
@interface ScannerViewController : UIViewController <ZBarReaderDelegate> {
}
@property (strong, nonatomic) IBOutlet UILabel *readerResult;
@property (strong, nonatomic) IBOutlet UIView *readerView;
@property (strong, nonatomic) IBOutlet ZBarReaderView *zbr;
.m
- (void)viewDidLoad
{
[super viewDidLoad];
// force class to load so it may be referenced directly from nib
[ZBarReaderViewController class];
ZBarReaderViewController *reader= [ZBarReaderViewController new];
reader.readerDelegate = self;
ZBarImageScanner *scanner = reader.scanner;
//reader.cameraOverlayView = self.readerView;
[scanner setSymbology: 0
config: ZBAR_CFG_ENABLE
to: 1];
[reader setShowsZBarControls:NO];
[reader.readerView start];
self.zbr = reader.readerView;
[self.view addSubview:reader.view];
}
- (void) zbr: (ZBarReaderView*) view
didReadSymbols: (ZBarSymbolSet*) syms
fromImage: (UIImage*) img
{
NSLog(@"Scanner used");
//do something useful with results and display resultText in resultViewController
for(ZBarSymbol *sym in syms) {
NSLog(@"Logged");
//return resultText;
break;
}
}
Any advice would be great. I'm getting very confused with this at the moment. Cheers.