1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- //
- // DIYScanViewController.m
- // LBXScanDemo
- //
- // Created by lbxia on 2017/6/5.
- // Copyright © 2017年 lbx. All rights reserved.
- //
- #import "DIYScanViewController.h"
- #import "LBXAlertAction.h"
- #import "LBXScanTypes.h"
- @interface DIYScanViewController ()
- @end
- @implementation DIYScanViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- self.cameraInvokeMsg = @"相机启动中";
- }
- #pragma mark -实现类继承该方法,作出对应处理
- - (void)scanResultWithArray:(NSArray<LBXScanResult*>*)array
- {
- if (!array || array.count < 1)
- {
- [self popAlertMsgWithScanResult:nil];
-
- return;
- }
-
- //经测试,可以ZXing同时识别2个二维码,不能同时识别二维码和条形码
- // for (LBXScanResult *result in array) {
- //
- // NSLog(@"scanResult:%@",result.strScanned);
- // }
-
- LBXScanResult *scanResult = array[0];
-
- NSString*strResult = scanResult.strScanned;
-
- self.scanImage = scanResult.imgScanned;
-
- if (!strResult) {
-
- [self popAlertMsgWithScanResult:nil];
-
- return;
- }
-
- //TODO: 这里可以根据需要自行添加震动或播放声音提示相关代码
- //...
-
- [self showNextVCWithScanResult:scanResult];
- }
- - (void)popAlertMsgWithScanResult:(NSString*)strResult
- {
- if (!strResult) {
-
- strResult = @"识别失败";
- }
-
- __weak __typeof(self) weakSelf = self;
- [LBXAlertAction showAlertWithTitle:@"扫码内容" msg:strResult buttonsStatement:@[@"知道了"] chooseBlock:^(NSInteger buttonIdx) {
-
- [weakSelf reStartDevice];
- }];
- }
- - (void)showNextVCWithScanResult:(LBXScanResult*)strResult
- {
- NSLog(strResult.imgScanned);
- // ScanResultViewController *vc = [ScanResultViewController new];
- // vc.imgScan = strResult.imgScanned;
- //
- // vc.strScan = strResult.strScanned;
- //
- // vc.strCodeType = strResult.strBarCodeType;
- //
- // [self.navigationController pushViewController:vc animated:YES];
- }
- @end
|