ZSQRCodeReader 0.1.2

ZSQRCodeReader 0.1.2

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2018年7月

safiri 维护。



  • safiriGitHub

QRCodeReader

介绍

二维码/条形码扫描读取,界面及交互模仿微信。相册照片选择依赖于第三方库TZImagePickerController

安装

pod "ZSQRCodeReader"

示例

- (IBAction)scanButtonClick:(id)sender {
    
    if ([ZSQRCodeReaderVC isReadyForCodeReader]) {
        ZSQRCodeReaderVC *codeReaderVC = [[ZSQRCodeReaderVC alloc] init];
        //@weakify(self)
        //@weakify(codeReaderVC)
        __weak typeof (self) weakSelf = self;
        __weak typeof (codeReaderVC) weakCodeReaderVC = codeReaderVC;
        codeReaderVC.completeBlock = ^(NSString *QRString) {
            //@strongify(self)
            //@strongify(codeReaderVC)
            NSLog(@"扫码result: %@", QRString);
            
            [weakCodeReaderVC.navigationController popViewControllerAnimated:YES];
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"扫码result" message:QRString preferredStyle:UIAlertControllerStyleAlert];
            [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:0 handler:nil]];
            [weakSelf presentViewController:alert animated:YES completion:nil];
        };
        codeReaderVC.errorBlock = ^(NSString * _Nullable errorMsg) {
            //@strongify(self);
            //@strongify(codeReaderVC);
            [weakCodeReaderVC.navigationController popViewControllerAnimated:YES];
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"扫码错误" message:errorMsg preferredStyle:UIAlertControllerStyleAlert];
            [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:0 handler:nil]];
            [weakSelf presentViewController:alert animated:YES completion:nil];
        };
        codeReaderVC.scanLabelHintString = @"将条形码放入框内,即可自动扫描";
        [self.navigationController pushViewController:codeReaderVC animated:YES];
    }else {
        
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"无法扫码" message:@"初始化失败,请重试" preferredStyle:UIAlertControllerStyleAlert];
        [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:0 handler:nil]];
        [self presentViewController:alert animated:YES completion:nil];
    }

}

一些截图

作者

safiriGitHub, [邮箱地址隐藏]