扫描相册中的二维码
2015-11-09 15:26
363 查看
直接上代码:
0.代理协议
UIImagePickerControllerDelegate, UINavigationControllerDelegate
1.定义
@property (strong, nonatomic) CIDetector *detector;
2.“相册”按钮的点击事件
3.照片选择后的代理方法
0.代理协议
UIImagePickerControllerDelegate, UINavigationControllerDelegate
1.定义
@property (strong, nonatomic) CIDetector *detector;
2.“相册”按钮的点击事件
-(void)clickRightBarButton:(UIBarButtonItem*)item { self.detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{ CIDetectorAccuracy : CIDetectorAccuracyHigh }]; UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.allowsEditing = NO; picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; [self.navigationController presentViewController:picker animated:YES completion:nil]; }
3.照片选择后的代理方法
- ( void )imagePickerController:( UIImagePickerController *)picker didFinishPickingMediaWithInfo:( NSDictionary *)info { [picker dismissViewControllerAnimated:YES completion:nil]; UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; if (!image){ image = [info objectForKey:UIImagePickerControllerOriginalImage]; } NSArray *features = [self.detector featuresInImage:[CIImage imageWithCGImage:image.CGImage]]; if (features.count >=1) { CIQRCodeFeature *feature = [features objectAtIndex:0]; NSString *scannedResult = feature.messageString; NSLog(@" ---- %@", scannedResult); NSArray *typeArray = [scannedResult componentsSeparatedByString:@","]; if (typeArray.count <= 0) { return; } // 分析扫描结果 [self analyzeQRCode:typeArray]; } }
相关文章推荐
- 表空间统计报告 Tablespace growth Report
- RecyclerView通过notifyItemChanged方法更新item数据避免闪烁
- 浅析js中substring和substr的方法
- BIEEE 创建多维钻取分析(4)
- Sublime text2如何设置快捷键让编写的HTML文件在浏览器预览?
- ubuntu下配置rsync,实现远程备份
- 计算机图形学:机器人的画法与填充
- 一阶RC低通滤波器杂记
- Java动态代理的两种实现方法
- 关于Ubuntu上建立express项目后执行node app.js没反应的问题
- easyui datagrid
- Android Context完全解析,你所不知道的Context的各种细节
- Android性能优化典范B4
- JAVA学习6_Eclipse打开已有工程和导入jar包
- Python学习之路六---迭代器、生成器
- FreeRTOS 队列例程Demo
- Java 工厂模式
- BIEE 创建一个简单的分析(2)
- fastqc, Per Base Sequence Content
- 成大事者必备的九种能力、九种手段、九种心态