使用Zbar实现简单的二维码扫描

导入ZBarSDK导入系统库 AVFoundation.framework,CoreMedia.framework,CoreVideo.framework,QuartzCore.framework,libiconv.tbd

如下图

使用Zbar实现简单的二维码扫描

设置1

使用Zbar实现简单的二维码扫描

设置2

使用Zbar实现简单的二维码扫描

在控制器类里加入如下代码

#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

上一篇:转】Maven学习总结(七)——eclipse中使用Maven创建Web项目


下一篇:fidder https以及Fiddler抓取HTTPS协议