扫描二维码的开源库有很多如 ZBarZXing

 

ZBar的使用方法:

下载ZBar SDK

地址https://github.com/bmorton/ZBarSDK

 

ZBarSDK是一个开源的SDK,该SDK实现了识别和读取各种条形码,包括EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, Interleaved 2 of 5 QR Code

 

Step1.使用ZBarSDK 需要导入的framework

1.AVFoundation.framework

2.CoreMedia.framework

3.CoreVideo.framework

4.QuartzCore.framework

5.libiconv.dylib

Step2.ViewController.h 导入#import "ZBarSDK.h"

Step3.ViewController.h 实现 <ZBarReaderDelegate>协议

Step4.写代码:

 

- (IBAction)scan:(id)sender {

     

     

ZBarReaderViewController * reader = [ZBarReaderViewController new];

    reader.readerDelegate = self;

    ZBarImageScanner * scanner = reader.scanner;

    [scanner setSymbology:ZBAR_I25 config:ZBAR_CFG_ENABLE to:0];

 

    reader.showsZBarControls = YES;

     

    [self presentViewController:reader animated:YES completion:nil];

 

}

 

 

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{

    id<NSFastEnumeration> results = [info objectForKey:ZBarReaderControllerResults];

    ZBarSymbol * symbol;

    for(symbol in results)

        break;

     

    _imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];

     

    [picker dismissViewControllerAnimated:YES completion:nil];

     

    _label.text = symbol.data;

}

相关文章:

  • 2022-02-24
  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
  • 2021-10-31
  • 2022-12-23
猜你喜欢
  • 2021-10-08
  • 2021-08-16
  • 2021-09-24
  • 2021-12-03
  • 2021-12-14
  • 2022-01-26
  • 2022-02-10
相关资源
相似解决方案