IOS QR code scan through ZBar ZXing and other third-party libraries, zbarzxing

Source: Internet
Author: User

IOS QR code scan through ZBar ZXing and other third-party libraries, zbarzxing

There are many open-source libraries for scanning QR codes, such as ZBar and ZXing.

 

How to Use ZBar:

Download ZBar SDK

Address https://github.com/bmorton/ZBarSDK

 

ZBarSDK is an open source SDK that implements the identification and reading of various bar codes, including EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, Interleaved 2 of 5 and QR Code.

 

Step1. the framework to be imported using ZBarSDK

1. AVFoundation. framework

2. CoreMedia. framework

3. CoreVideo. framework

4. QuartzCore. framework

5. libiconv. dylib

Step 2 import # import "ZBarSDK. h" in ViewController. h"

Step3. implement the <ZBarReaderDelegate> protocol in ViewController. h.

Step 4. Write the Code:

 

-(IBAction) scan :( id) sender {

ZBarReaderViewController * reader = [ZBarReaderViewControllerNew];

Reader. readerDelegate = self;

Zbarimageworkflow * reader. Category = reader. category;

[Export setSymbology: ZBAR_I25 config: zbar_assist_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;

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.