导入ZBarSDK导入系统库 AVFoundation.framework,CoreMedia.framework,CoreVideo.framework,QuartzCore.framework,libiconv.tbd
如下图
设置1
设置2
在控制器类里加入如下代码
#import "ViewController.h"
#import "ZBarSDK.h"
@interface ViewController ()<ZBarReaderDelegate>
@property (strong, nonatomic) IBOutlet UIImageView *showImage;
@property (strong, nonatomic) IBOutlet UILabel *showContenLab;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (IBAction)startScanBtn:(id)sender {
ZBarReaderController *readCtl = [ZBarReaderController new];
readCtl.readerDelegate = self;
ZBarImageScanner *scanner = readCtl.scanner;
[scanner setSymbology:ZBAR_I25 config:ZBAR_CFG_ENABLE to:0];
readCtl.showsZBarControls = YES;
[self presentViewController:readCtl animated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
id<NSFastEnumeration>resluts = [info objectForKey:ZBarReaderControllerResults];
ZBarSymbol *symbol;
for (symbol in resluts)
{
break;
}
self.showImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];
[picker dismissViewControllerAnimated:YES completion:nil];
self.showContenLab.text = symbol.data;
// NSURL *url = [NSURL URLWithString:symbol.data];
// [[UIApplication sharedApplication] openURL:url];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end