我正在尝试将Zbarsdk包含在我现有的应用程序中......我发现readertest示例确实是一个很好的示例,因为它包含所有功能和选项但是该示例仅包含名为“reader test.m”的.m文件,其中包含AppDelegate嵌入它...它也没有xib,因为所有初始化都是以编程方式进行的...所以如何将它添加到我的应用程序中,它有一个扫描代码的选项?
答案 0 :(得分:0)
导入ZBarSDK文件夹,该文件夹应包含libzbar.a库以及头文件和资源文件。
现在在导入" ZBarReaderController.h"后使用ZBarReaderDelegate;文件并使用以下功能:
-(IBAction) scan
{
NSLog(@" SCAN BARCODE BUTTON TAPPED ");
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.showsHelpOnFail = YES;
ZBarImageScanner *scanner = reader.scanner;
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
[self presentModalViewController:reader animated:YES];
}
- (void) imagePickerController: (UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info
{
id<NSFastEnumeration> results = info[ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for(symbol in results)
break;
NSString *EANCode = symbol.data;
[reader dismissModalViewControllerAnimated: YES];
// so you have got the EAN code as result use it in your app
}