//
//  ViewController.m
//  ZBarReaderViewController
//
//  Created by City--Online on 15/6/9.
//  Copyright (c) 2015年 CYW. All rights reserved.
//

#import "ViewController.h"
#import "ZBarSDK.h"

@interface ViewController ()<ZBarReaderDelegate>
@property(nonatomic,strong) UIImageView *imgView;
@property(nonatomic,strong) UILabel *label;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIButton *btn=[UIButton buttonWithType:UIButtonTypeSystem];
    [btn setTitle:@"扫你" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    btn.frame=CGRectMake(, , , );
    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];

    _imgView=[[UIImageView alloc]initWithFrame:CGRectMake(, , , )];
    [self.view addSubview:_imgView];

    _label=[[UILabel alloc]initWithFrame:CGRectMake(, , , )];
    [_label setTextColor:[UIColor redColor]];
    [self.view addSubview:_label];
}
-(void)btnClick:(id)sender
{
    ZBarReaderViewController *reader=[[ZBarReaderViewController alloc]init];
    reader.readerDelegate=self;
    ZBarImageScanner *scanner=reader.scanner;
    [scanner setSymbology:ZBAR_I25 config:ZBAR_CFG_ENABLE to:];
    reader.showsZBarControls=YES;
    reader.showsHelpOnFail=NO;
//    reader.showsCameraControls=YES;
    [self presentViewController:reader animated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    id<NSFastEnumeration> results = [info objectForKey:ZBarReaderControllerResults];
    ZBarSymbol * symbol;
    for(symbol in results)
        break;

    _imgView.image = [info objectForKey:UIImagePickerControllerOriginalImage];

    [picker dismissViewControllerAnimated:YES completion:nil];

    _label.text = symbol.data;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

ZBar之ZBarReaderViewController的更多相关文章

  1. iphone 开发中使用zbar时遇到的几个典型问题解决方法。

    iphone 开发中使用zbar时遇到的几个典型问题解决方法.   在近期的一个ios项目中使用到了一个二维码扫描库(Qrcode)--ZBar, 期间遇到2个问题.   1. zbar下载后使用其l ...

  2. ZBar与ZXing使用后感觉

    [原]ZBar与ZXing使用后感觉(上) 2014-3-18阅读2011 评论1 最近对二维码比较感兴趣,还是那句老话,那么我就对比了一下zxing和zbar 如果对于这两个的背景不了解的话,可以看 ...

  3. 二维码ZBar之ZBarReaderView

    参考:http://www.chinatarena.com/Html/iospeixun/201301/3985.html   http://blog.csdn.net/chenyong05314/a ...

  4. 在iOS中使用ZBar扫描二维码

    最近在做的项目中需要用到二维码扫描功能,之前在Android中使用过ZXing识别二维码,ZXing也有对应的iOS版本,经过了解,ZBar也是一个常用的二维码识别软件,并分别提供了iOS和Andro ...

  5. ZBar的简单使用

    NSRunLoop类声明的编程接口用于管理输入源对象.一个NSRunLoop对象处理像来自窗体系统中的鼠标和键盘事件,NSPORT对象和NSConnection连接对象这类的输入源.一个NSRunLo ...

  6. iOS 二维码扫描 通过ZBar ZXing等第三方库

    扫描二维码的开源库有很多如 ZBar.ZXing等 ZBar的使用方法: 下载ZBar SDK 地址https://github.com/bmorton/ZBarSDK ZBarSDK是一个开源的SD ...

  7. iOS-条形码扫描技术SDK:ZBar(转)

    ios条形码扫描技术 iOS 应用里实现条形码扫描功能,有个免费开源的 SDK:ZBar(http://zbar.sourceforge.net/iphone/sdkdoc/install.html) ...

  8. 在iOS中使用ZBar扫描二维码和条形码

    最近做了个外包项目,里面用到了二维码扫描和微信支付!之前比较熟悉的是ZXing,但是在Xcode7.1里面发现竟然莫名的不支持,木有办法,从网上查了一下还有一种支持二维码扫描的东西,没错就是接下来我要 ...

  9. C#使用zxing,zbar,thoughtworkQRcode解析二维码,附源代码

    最近做项目需要解析二维码图片,找了一大圈,发现没有人去整理下开源的几个库案例,花了点时间 做了zxing,zbar和thoughtworkqrcode解析二维码案例,希望大家有帮助. zxing是谷歌 ...

随机推荐

  1. 微信Web APP应用

    微信Web APP即微信公众账号,对web APP的提供者来说这是一个门槛极低,容易到达数亿真实用户且确保用户黏性的分发平台;对用户来说,这是一种前所未有及其简单的应用使用方式;对腾讯来 说,将形成微 ...

  2. linux系统编程之文件与IO(五):stat()系统调用获取文件信息

    一.stat()获取文件元数据 stat系统调用原型: #include <sys/stat.h> int stat(const char *path, struct stat *buf) ...

  3. 【mysql】Windows环境搭建(适用5.7以上)

    1 下载MySQL 登录 https://dev.mysql.com/downloads/mysql/ 2 配置 下载好了zip文件,解压至任意非中文目录,在根目录下新建my.ini: 输入以下内容( ...

  4. XCode - vmware虚拟机安装XCode进行iPhone真机调试

    1.vmware安装黑苹果,然后在appStore安装XCode http://blog.csdn.net/forgot2015/article/details/51104329 2.真机调试证书等申 ...

  5. css3效果隔两秒旋转然后停两秒再继续旋转,无限循环

    1.旋转效果 <style type="text/css"> /*底部天象APP红包下载*/ .public_footer_app,.animation{ positi ...

  6. Linux core 文件 gdb

    http://blog.csdn.net/mr_chenping/article/details/13767609 在程序不寻常退出时,内核会在当前工作目录下生成一个core文件(是一个内存映像,同时 ...

  7. 找到SVN版本机上项目的地址

    在你的项目文件上右击:点击Copy URL to Clipboard(复制URL到剪切板)

  8. 记一次使用SecureCRT连接局域网巨慢的问题

    环境:Win7 32bit + SecureCRT 6.5 中文 使用工作机上的SecureCRT登录公司内网的跳板机,发现很慢,每次都得等待好几分钟才弹出输出私匙密码的框.咨询了一下其他同事,发现他 ...

  9. 将一个List拆分为n份的方法

    public static void main(String[] args) { List<Integer> taskList = new ArrayList<>(); for ...

  10. JSON JSONPath

    JSONPath is a query language for JSON, similar to XPath for XML. AlertSite API endpoint monitors let ...