博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ZBar之ZBarReaderViewController
阅读量:6560 次
发布时间:2019-06-24

本文共 2013 字,大约阅读时间需要 6 分钟。

////  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 ()
@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(10, 100, 60, 40); [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn]; _imgView=[[UIImageView alloc]initWithFrame:CGRectMake(100, 200, 200, 200)]; [self.view addSubview:_imgView]; _label=[[UILabel alloc]initWithFrame:CGRectMake(10, 150, 300, 40)]; [_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:0]; reader.showsZBarControls=YES; reader.showsHelpOnFail=NO;// reader.showsCameraControls=YES; [self presentViewController:reader animated:YES completion:nil];}-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ id
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

转载地址:http://dxzjo.baihongyu.com/

你可能感兴趣的文章
redhat5.8+mfs(提供软件包文档)
查看>>
python编写登录接口
查看>>
MySQL高可用方案之多级复制
查看>>
OVS 中的各种网络设备 - 每天5分钟玩转 OpenStack(128)
查看>>
Python火车票代码
查看>>
Android开发者指南(7) —— App Install Location
查看>>
Trafficserver Cluster模式
查看>>
亚马逊推出 Blox,用于 EC2 容器服务的开源工具集合
查看>>
Linux:在中国没有真正的新闻
查看>>
iOS推送功能极光推送的介绍与实现
查看>>
单用户模式与grub加密
查看>>
Chromium Graphics: 3D上下文及其虚拟化 - Part I
查看>>
jquery javascript获得网页的高度和宽度
查看>>
2019 -2-15 复习
查看>>
vim锁定屏幕
查看>>
实用的 JavaScript 调试小技巧
查看>>
027移除元素
查看>>
Linux下清理内存和Cache方法
查看>>
CodeVS 1018 单词接龙(DFS)
查看>>
我的博客园的CSS和html设置
查看>>