IOS 开发学习七 二维码扫描功能(ZBar SDK)
2015-04-29 16:11
281 查看
1.下载:
点击打开链接
2.拖动下载的sdk到项目里,选择 copy
3.添加framework
完整的文档在Documentation.html里。
4.如果编译有如下错误:
"_OBJC_CLASS_$_ZBarReaderViewController", referenced from ...
则到Targets设置:
4.在Controller.h里加代码:
在Controller.m里加代码:
点击打开链接
2.拖动下载的sdk到项目里,选择 copy
3.添加framework
* AVFoundation.framework (weak) * CoreMedia.framework (weak) * CoreVideo.framework (weak) * QuartzCore.framework * libiconv.dylib
完整的文档在Documentation.html里。
4.如果编译有如下错误:
"_OBJC_CLASS_$_ZBarReaderViewController", referenced from ...
则到Targets设置:
4.在Controller.h里加代码:
#import <UIKit/UIKit.h> @interface ReaderSampleViewController : UIViewController { } @property (weak, nonatomic) IBOutlet UIImageView *resultImage; @property (weak, nonatomic) IBOutlet UILabel *resultText; - (IBAction) scanButtonTapped; @end
在Controller.m里加代码:
#import "ReaderSampleViewController.h" #import "ZBarSDK.h" @interface ReaderSampleViewController () { } @end @implementation ReaderSampleViewController @synthesize resultImage,resultText; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)scanButtonTapped{ NSLog(@"Barcode scan "); ZBarReaderViewController *reader = [ZBarReaderViewController new]; reader.readerDelegate = self; reader.supportedOrientationsMask = ZBarOrientationMaskAll; ZBarImageScanner *scanner = reader.scanner; // TODO: (optional) additional reader configuration here // EXAMPLE: disable rarely used I2/5 to improve performance [scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to: 0]; // present and release the controller [self presentModalViewController: reader animated: YES]; //[reader release]; } - (void) dealloc{ self.resultText=nil; self.resultImage=nil; //[super dealloc]; } - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ return true; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ - (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info { // ADD: get the decode results id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults]; ZBarSymbol *symbol = nil; for(symbol in results) // EXAMPLE: just grab the first barcode break; // EXAMPLE: do something useful with the barcode data resultText.text = symbol.data; // EXAMPLE: do something useful with the barcode image resultImage.image = [info objectForKey: UIImagePickerControllerOriginalImage]; // ADD: dismiss the controller (NB dismiss from the *reader*!) [reader dismissModalViewControllerAnimated: YES]; } @end
相关文章推荐
- IOS开发---菜鸟学习之路--(二十)-二维码扫描功能的实现
- IOS开发---菜鸟学习之路--(十五)-如何实现拍照功能
- iOS开发学习笔记:使用xcode里的单元测试,放在STAssert…里面的语句无法使用自动完成功能
- 【iOS开发-54】案例学习:通过UIScrollView的缩放图片功能练习代理模式的具体实现
- IOS开发---菜鸟学习之路--(十五)-如何实现拍照功能
- IOS开发---菜鸟学习之路--(十五)-如何实现拍照功能
- iOS开发学习之UI篇2、AppDelegate.m文件中方法的主要功能
- IOS开发-OC学习-常用功能代码片段整理
- iOS学习应用开发就业课_003:UIButton基本功能
- iOS 开发中关于支付功能的学习心得 ----支付宝
- iOS开发学习-类似微信聊天消息中的电话号码点击保存到通讯录中的功能
- ios开发学习笔记--数据持久化之归档解档(NSKeyedArchiver/ NSKeyedUnarchiver)
- iOS开发学习之关键字Typedef的用法详解
- iOS开发之安全学习资料汇总,史上最全安全学习资料
- 微信开发学习总结(三)——开发微信公众号的最基本功能——普通消息的接收和回复
- iOS开发-由浅至深学习block
- ios开发学习笔记--数据持久化之数据库(SQLite.swift)
- 大家好,我是筱鹏,日后我将会在我的博客不定期更新IOS开发的自定实用小功能
- ios开发学习笔记--数据持久化之Core Data
- IOS开发学习-基础环境搭建-1