QRCodeScanForChangeDeviceViewController.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. //
  2. // QRCodeScanForChangeDeviceViewController.m
  3. // 隐私保护
  4. //
  5. // Created by APPLE on 2023/9/19.
  6. //
  7. #import "QRCodeScanForChangeDeviceViewController.h"
  8. #import <AVFoundation/AVFoundation.h>
  9. #import <ImageIO/ImageIO.h>
  10. #import "RSATool.h"
  11. #import "connectDeviceManager.h"
  12. #import "uploadFileManager.h"
  13. #import "downloadManager.h"
  14. #import "backupsFileManager.h"
  15. #import <TZImageManager.h>
  16. #import <TZImagePickerController.h>
  17. #import "boxDownloadFileManager.h"
  18. @interface QRCodeScanForChangeDeviceViewController ()<AVCaptureMetadataOutputObjectsDelegate,AVCaptureVideoDataOutputSampleBufferDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate,TZImagePickerControllerDelegate>
  19. @property(nonatomic,strong)AVCaptureVideoPreviewLayer *layer;
  20. //捕捉会话
  21. @property(nonatomic,strong)AVCaptureSession *session;
  22. //辅助区域框
  23. @property(nonatomic,strong)UIImageView * cyanEdgeImageView;
  24. @property(nonatomic,strong)UIImageView * qrCodeScanLine;
  25. @property(nonatomic,strong)NSTimer * scanLineTimer;
  26. ////打开灯光btn,默认为hidden
  27. //
  28. //@property(nonatomic,strong)UIButton * lightBtn;
  29. //
  30. ////获取相册图片进行扫描
  31. //
  32. //@property(nonatomic,strong)UIButton * photoBtn;
  33. @end
  34. @implementation QRCodeScanForChangeDeviceViewController
  35. - (void)viewDidLoad {
  36. [super viewDidLoad];
  37. // Do any additional setup after loading the view.
  38. [self.navigationBar setHidden:YES];
  39. [self.toolBar setHidden:YES];
  40. AVAuthorizationStatus authStatus =[AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
  41. //判断摄像头状态是否可用
  42. if(authStatus==AVAuthorizationStatusAuthorized){
  43. [self startScan];
  44. }else{
  45. NSLog(@"未开启相机权限,请前往设置中开启");
  46. [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
  47. if (granted){
  48. mainBlock(^{
  49. [self startScan];
  50. });
  51. }
  52. }];
  53. }
  54. }
  55. -(void)viewWillDisappear:(BOOL)animated
  56. {
  57. [super viewWillDisappear:animated];
  58. [_scanLineTimer invalidate];
  59. }
  60. //开始扫描二维码
  61. -(void)startScan{
  62. //1.创建捕捉会话,AVCaptureSession是第一个要被创建的对象,所有的操作都要基于这一个session
  63. self.session = [[AVCaptureSession alloc]init];
  64. AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
  65. AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:nil];
  66. [self.session addInput:input];
  67. //3.添加输出数据(示例对象-->类对象-->元类对象-->根元类对象)
  68. /*输入的类是AVCaptureInput,那么输出的类相应的就应该是AVCaptureOutput。
  69.  输出不需要和设备挂钩,因为一般情况下,我们的输出要么是音频或视频文件,要么是一些其他的数据,像二维码扫描一般是字符串类型。
  70.  所以创建AVCaptureOutput实例就不需要AVCaptureDevice对象。
  71.  AVCaptureOutput也同样是一个抽象类,同样要使用其子类,在这里我们扫描二维码,
  72.  使用的是AVCaptureMetadataOutput,设置代码如下所示*/
  73. AVCaptureMetadataOutput *output = [[AVCaptureMetadataOutput alloc] init];
  74. [output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
  75. //设置能扫描的区域,这里注意,CGRectMake的x,y和width,height的值是互换位置
  76. output.rectOfInterest=CGRectMake(250/self.view.frame.size.height, 100/self.view.frame.size.width, (self.view.frame.size.width-200)/self.view.frame.size.width, (self.view.frame.size.width-200)/self.view.frame.size.width);
  77. [self.session addOutput:output];
  78. //设置输入元数据的类型(类型是二维码,条形码数据,注意,这个一定要写在添加到session后面,不然要崩溃,如果只需要扫描二维码只需要AVMetadataObjectTypeQRCode,如果还需要扫描条形码,那么全部添加上)
  79. [output setMetadataObjectTypes:@[AVMetadataObjectTypeQRCode,
  80. AVMetadataObjectTypeEAN8Code,
  81. AVMetadataObjectTypeEAN13Code,
  82. AVMetadataObjectTypeCode39Code,
  83. AVMetadataObjectTypeCode39Mod43Code,
  84. AVMetadataObjectTypeCode93Code,
  85. AVMetadataObjectTypeCode128Code,
  86. AVMetadataObjectTypePDF417Code,
  87. AVMetadataObjectTypeAztecCode,
  88. AVMetadataObjectTypeUPCECode,
  89. AVMetadataObjectTypeInterleaved2of5Code,
  90. AVMetadataObjectTypeITF14Code,
  91. AVMetadataObjectTypeDataMatrixCode,
  92. ]];
  93. //4.添加扫描图层
  94. self.layer = [AVCaptureVideoPreviewLayer layerWithSession:self.session];
  95. self.layer.videoGravity=AVLayerVideoGravityResizeAspectFill;
  96. self.layer.frame = self.view.bounds;
  97. [self.view.layer addSublayer:self.layer];
  98. //5.创建view,通过layer层进行设置边框宽度和颜色,用来辅助展示扫描的区域
  99. _cyanEdgeImageView=[[UIImageView alloc] initWithFrame:CGRectMake(100, 250, self.view.frame.size.width-200, self.view.frame.size.width-200)];
  100. // _cyanEdgeImageView.layer.borderWidth=2;
  101. //
  102. // _cyanEdgeImageView.layer.borderColor =[UIColor cyanColor].CGColor;
  103. _cyanEdgeImageView.image = [UIImage imageNamed:@"qrCode_scan_bg"];
  104. [self.view addSubview:_cyanEdgeImageView];
  105. _qrCodeScanLine=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width-200, 1)];
  106. _qrCodeScanLine.image = [UIImage imageNamed:@"qrCode_scan_line"];
  107. [_cyanEdgeImageView addSubview:_qrCodeScanLine];
  108. _scanLineTimer = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(scanLineDownAndUpFun) userInfo:nil repeats:YES];
  109. UILabel *tipLib = [[UILabel alloc] initWithFrame:CGRectMake(20, _cyanEdgeImageView.hw_max_y + 15, SCREEN_W - 40, 20)];
  110. tipLib.text = NSLocalizedString(@"guide_qrcoede_tips_please",nil);
  111. tipLib.font = [UIFont systemFontOfSize:14.0];
  112. tipLib.textAlignment = NSTextAlignmentCenter;
  113. tipLib.textColor = [UIColor whiteColor];
  114. [self.view addSubview:tipLib];
  115. //6.创建检测光感源
  116. AVCaptureVideoDataOutput *guangOutPut = [[AVCaptureVideoDataOutput alloc] init];
  117. [guangOutPut setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
  118. //设置为高质量采集率
  119. [self.session setSessionPreset:AVCaptureSessionPresetHigh];
  120. //把光感源添加到会话
  121. [self.session addOutput:guangOutPut];
  122. // self.lightBtn=[[UIButton alloc]initWithFrame:CGRectMake(150, cyanView.frame.origin.y+cyanView.frame.size.height+100, self.view.frame.size.width-300, self.view.frame.size.width-300)];
  123. //
  124. // self.lightBtn.backgroundColor=[UIColor grayColor];
  125. //
  126. // [self.lightBtn addTarget:self action:@selector(lightBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  127. //
  128. // [self.view addSubview:self.lightBtn];
  129. // self.photoBtn=[[UIButton alloc]initWithFrame:CGRectMake(100, self.lightBtn.frame.origin.y+self.lightBtn.frame.size.height+50, self.view.frame.size.width-200, 50)];
  130. //打开相册
  131. UIButton *openAlbunBut = [[UIButton alloc] init];
  132. [openAlbunBut setTitle:NSLocalizedString(@"guide_qrcoede_open_album",nil) forState:UIControlStateNormal];
  133. [openAlbunBut setTitleColor:[UIColor hwColor:@"#3B7FFF" alpha:1.0] forState:UIControlStateNormal];
  134. openAlbunBut.titleLabel.font = [UIFont systemFontOfSize:14.0];
  135. [openAlbunBut addTarget:self action:@selector(photoBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  136. openAlbunBut.backgroundColor = [UIColor hwColor:@"#FFFFFF" alpha:0.2];
  137. [self.view addSubview:openAlbunBut];
  138. openAlbunBut.layer.cornerRadius = 24;
  139. openAlbunBut.layer.masksToBounds = YES;
  140. [openAlbunBut mas_makeConstraints:^(MASConstraintMaker *make) {
  141. make.width.mas_equalTo(140);
  142. make.height.mas_equalTo(48);
  143. make.centerX.mas_equalTo(0);
  144. make.bottom.mas_equalTo(-80);
  145. }];
  146. // [self.photoBtn setTitle:@"相册" forState:UIControlStateNormal];
  147. // [self.photoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  148. // self.photoBtn.backgroundColor=[UIColor orangeColor];
  149. // [self.photoBtn addTarget:self action:@selector(photoBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  150. // [self.view addSubview:self.photoBtn];
  151. //9.开始扫描
  152. [self.session startRunning];
  153. //添加返回键
  154. CGFloat btn_w_h = 40;
  155. CGFloat btn_show = 28;
  156. UIButton *backBtn = [[UIButton alloc] init];
  157. [self.view addSubview:backBtn];
  158. [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  159. make.top.mas_equalTo(H_STATE_BAR + (64.f - btn_w_h)/2.f);
  160. make.left.mas_equalTo(10);
  161. make.width.mas_equalTo(btn_w_h);
  162. make.height.mas_equalTo(btn_w_h);
  163. }];
  164. [backBtn setImage:[UIImage imageNamed:@"icon_base_back"] forState:(UIControlStateNormal)];
  165. [backBtn setImageEdgeInsets:(UIEdgeInsetsMake((btn_w_h - btn_show)/2.f, (btn_w_h - btn_show)/2.f, (btn_w_h - btn_show)/2.f, (btn_w_h - btn_show)/2.f))];
  166. [backBtn addTarget:self
  167. action:@selector(backBtnPressed)
  168. forControlEvents:(UIControlEventTouchUpInside)];
  169. }
  170. #pragma mark timer 处理线上下移动
  171. bool isDownType22 = YES;
  172. -(void)scanLineDownAndUpFun
  173. {
  174. [UIView animateWithDuration:0.01 animations:^{
  175. if(isDownType22 && self->_qrCodeScanLine.hw_y <= self->_cyanEdgeImageView.hw_h){
  176. self->_qrCodeScanLine.hw_y += 2;
  177. if(self->_cyanEdgeImageView.hw_h - self->_qrCodeScanLine.hw_y <= 5){
  178. isDownType22 = NO;
  179. }
  180. }
  181. else if(!isDownType22 && self->_qrCodeScanLine.hw_y >= 0)
  182. {
  183. self->_qrCodeScanLine.hw_y -= 2;
  184. if(self->_qrCodeScanLine.hw_y <= 5){
  185. isDownType22 = YES;
  186. }
  187. }
  188. }];
  189. }
  190. //实现扫描的回调代理方法
  191. - (void)captureOutput:(AVCaptureOutput*)captureOutput didOutputMetadataObjects:(NSArray*)metadataObjects fromConnection:(AVCaptureConnection*)connection{
  192. //如果数组metadataObjects中有数据,metadataObjects是个数组类型
  193. if(metadataObjects.count>0) {
  194. AVMetadataMachineReadableCodeObject*object = [metadataObjects lastObject];
  195. NSLog(@"%@",object.stringValue);
  196. /*扫描到有用信息时取消扫描*/
  197. NSString *resStr = object.stringValue;//RK3908P1V62112465
  198. [self handleScanCodeResultFun:resStr];
  199. }else{
  200. //[[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_error",nil)] show];
  201. NSLog(@"没有扫描到数据");
  202. }
  203. }
  204. #pragma mark 处理扫码出来的数据
  205. - (void)handleScanCodeResultFun:(NSString*)resultStr
  206. {
  207. [[uploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
  208. [[downloadManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
  209. [[backupsFileManager shareInstance] suspendBackupsFileFun];
  210. [[boxDownloadFileManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
  211. NSString *resStr = resultStr;
  212. if(resStr.length > 22)
  213. {
  214. NSString*desStr = [RSATool AES128Decrypt:resStr key:AESCODEKEEYY];
  215. if(desStr){//能解码
  216. resStr = desStr;
  217. }
  218. }
  219. //Ch0IKJCY9lOgokjfPBFE1cowdC1+tj7ywB2pZgSzjhc=
  220. //sgl5OzDoVjY5SmGuL50/EnQ4n6Kw+DzRiE1oUjq7yAM=
  221. if (([resStr containsString:@"RK"] && (resStr.length == @"RK3908P1V62112465".length))
  222. || resStr.length == @"0333933700223250017273".length
  223. ){
  224. NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
  225. if (!deviceDict || [[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
  226. NSString *oldStr = deviceDict[Const_Have_Add_Device_SN];
  227. if([oldStr isEqualToString:resStr]){
  228. [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_change_same",nil)] show];
  229. //停止扫描
  230. [self.session stopRunning];
  231. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  232. [self.session startRunning];
  233. });
  234. return;
  235. }
  236. }
  237. //[[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_ok",nil)] show];
  238. [_scanLineTimer invalidate];
  239. //停止扫描
  240. [self.session stopRunning];
  241. //移除扫描层layer
  242. [self.layer removeFromSuperlayer];
  243. [self showNewIndicatorHaveStrWithCanBack:NO canTouch:NO showText:NSLocalizedString(@"guide_qrcoede_tips_ok",nil)];
  244. [[connectDeviceManager shareInstance] getThridMsgBySN:resStr needReconnect:YES didNetEnd:^(NSInteger didSuc) {
  245. [self removeNewIndicatorHaveStr];
  246. if(didSuc == 1){
  247. NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:deviceDict];
  248. [dict setObject:resStr forKey:Const_Have_Add_Device_SN];
  249. [HWDataManager setObjectWithKey:Const_Have_Add_Device value:dict];
  250. BOOL didSetBackWork = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_didSet_working_background)];
  251. if(!didSetBackWork){
  252. [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_didSet_working_background) value:YES];
  253. [HWDataManager setBoolWithKey:stringKeyAddSn(Const_file_Transfe_working_background) value:YES];
  254. }
  255. //尝试修复偶现扫码切换云机 已经扫码到 要输新SN密码 但是云机显示是旧SN的 延时一秒跳转
  256. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  257. [self.navigationController popToRootViewControllerAnimated:NO];
  258. [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
  259. });
  260. }else{
  261. // if(didSuc == 2){
  262. // [[iToast makeText:NSLocalizedString(@"scan_sn_data_error_tip",nil)] show];
  263. // }
  264. // else{
  265. // [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_get_SdnID_fail",nil)] show];
  266. // }
  267. if(self->_didScanErrorFun){
  268. self->_didScanErrorFun(didSuc);
  269. }
  270. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  271. mainBlock(^{
  272. [self.navigationController popViewControllerAnimated:YES];
  273. });
  274. });
  275. }
  276. }];
  277. }
  278. else{
  279. [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_error",nil)] show];
  280. }
  281. }
  282. //光感传感器代理
  283. -(void)captureOutput:(AVCaptureOutput*)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection*)connection{
  284. //获取光线的值
  285. CFDictionaryRef metadataDict = CMCopyDictionaryOfAttachments(NULL,sampleBuffer, kCMAttachmentMode_ShouldPropagate);
  286. NSDictionary *metadata = [[NSMutableDictionary alloc] initWithDictionary:(__bridge NSDictionary*)metadataDict];
  287. CFRelease(metadataDict);
  288. NSDictionary *exifMetadata = [[metadata objectForKey:(NSString *)kCGImagePropertyExifDictionary] mutableCopy];
  289. float brightnessValue = [[exifMetadata objectForKey:(NSString*)kCGImagePropertyExifBrightnessValue]floatValue];
  290. NSLog(@"%f",brightnessValue);
  291. // 根据brightnessValue的值来打开和关闭闪光灯,一般值小于0就需要打开,大于0就关闭
  292. // if((brightnessValue <0)) {//显示闪光灯
  293. // self.lightBtn.hidden=NO;
  294. // }else if((brightnessValue >0)) {//隐藏闪光灯
  295. // self.lightBtn.hidden=YES;
  296. // }
  297. }
  298. ////闪光灯按钮点击方法
  299. //
  300. //-(void)lightBtnClick:(UIButton*)sender{
  301. // //判断当前设备是否有闪光灯
  302. //
  303. // AVCaptureDevice * device=[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
  304. //
  305. // BOOL result=[device hasTorch];
  306. //
  307. // if(result==YES){
  308. // if(self.lightBtn.isSelected==NO){
  309. // self.lightBtn.selected=YES;
  310. // self.lightBtn.backgroundColor=[UIColor greenColor];
  311. // [device lockForConfiguration:nil];
  312. // [device setTorchMode: AVCaptureTorchModeOn];//开
  313. // [device unlockForConfiguration];
  314. // }else if(self.lightBtn.isSelected==YES){
  315. // self.lightBtn.selected=NO;
  316. // self.lightBtn.backgroundColor=[UIColor grayColor];
  317. // [device lockForConfiguration:nil];
  318. // [device setTorchMode: AVCaptureTorchModeOff];//关
  319. // [device unlockForConfiguration];
  320. // }
  321. // }else{
  322. // NSLog(@"当前设备闪光灯不可用");
  323. // }
  324. //}
  325. //
  326. ////获取相册图片btn点击方法
  327. -(void)photoBtnClick:(UIButton*)sender{
  328. // UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
  329. // imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  330. // // imagePicker.allowsEditing = YES;
  331. // imagePicker.delegate=self;
  332. // [self.navigationController presentViewController:imagePicker animated:YES completion:nil];
  333. [self photoClickFun];
  334. }
  335. - (void)photoClickFun
  336. {
  337. TZImagePickerController *imagePicker = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:self];
  338. imagePicker.allowPickingVideo=NO;
  339. //imagePicker.isStatusBarDefault=YES;
  340. imagePicker.allowTakePicture=NO;
  341. imagePicker.allowPreview = NO;
  342. // 4. 照片排列按修改时间升序
  343. imagePicker.sortAscendingByModificationDate = YES;
  344. [self presentViewController:imagePicker animated:YES completion:nil];
  345. }
  346. - (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto
  347. {
  348. if(photos && photos.count >= 1){
  349. [self detectImageFunBy:photos.firstObject];
  350. }
  351. else{
  352. [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_error",nil)] show];
  353. }
  354. }
  355. //UIImagePickerControllerDelegate选择图片的回调
  356. -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey,id> *)info {
  357. //把UIimage类型转换成CIimage类型
  358. UIImage *pickedImage = info[UIImagePickerControllerEditedImage] ?: info[UIImagePickerControllerOriginalImage];
  359. [picker dismissViewControllerAnimated:YES completion:^{
  360. }];
  361. [self detectImageFunBy:pickedImage];
  362. }
  363. #pragma mark 解析Uiimage
  364. - (void)detectImageFunBy:(UIImage*)pickedImage
  365. {
  366. CIImage*detectImage = [CIImage imageWithData:UIImagePNGRepresentation(pickedImage)];
  367. //解析扫描二维码结果字符串
  368. CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{CIDetectorAccuracy: CIDetectorAccuracyLow}];
  369. //CIQRCodeFeature*feature = (CIQRCodeFeature*)[detector featuresInImage:detectImage options:nil].firstObject;
  370. NSArray *messageStringArr = (CIQRCodeFeature*)[detector featuresInImage:detectImage options:nil];
  371. //排除掉 http的
  372. __block NSString *curQRCodeStr = nil;
  373. for(CIQRCodeFeature*feature in messageStringArr){
  374. if([feature.messageString rangeOfString:@"http"].location == NSNotFound){
  375. curQRCodeStr = feature.messageString;
  376. break;
  377. }
  378. }
  379. if(curQRCodeStr) {
  380. NSLog(@"=================二维码结果为%@",curQRCodeStr);
  381. [self handleScanCodeResultFun:curQRCodeStr];
  382. }else{
  383. [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_error",nil)] show];
  384. NSLog(@"没有扫描到数据");
  385. }
  386. // //停止会话对象扫描
  387. // [self.session stopRunning];
  388. // //移除扫描层layer
  389. // [self.layer removeFromSuperlayer];
  390. }
  391. @end