How to use two-dimensional code on Iphon IOS devices _ios

Source: Internet
Author: User

Here to introduce the next two-dimensional code introduction

The two-dimensional code (2-dimensional bar code) is a Black-and-white graphic recording data symbol information which is distributed in a plane (two-dimensional direction) by a certain geometry. The concept of "0", "1" bit flow that forms the basis of the internal logic of the computer is cleverly utilized in code compilation, Uses a number of geometric shapes corresponding to the binary to represent literal numeric information. Automatic reading through image input device or photoelectric scanning device to realize automatic information processing: Two-dimensional barcode/Two-D code can express information in both horizontal and vertical two directions, so it can express large amount of information in a very small area.

Here's how to use a two-dimensional code on an Apple iOS device:

1. Scan two-dimensional code (decode)

Scanning two-dimensional code of open source libraries are many such as Zbar, zxing and so on. This zbar is used as an example to construct two-dimensional code sweep code.

First download Zbar SDK on GitHub

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

Open the compression pack, which has the Zbarsdk folder

Include the Zbarsdk folder in the project

(Finder)
(XCode)

which contains a static library of LIBZBAR.A

Next, add the framework framework and the link library (dynamic library, Static library) to the project.

Linked frameworks and libraries are found in the project properties Targetssummary

Avfoundation.framwork, Coremedia.framework, Corevideo.framework, Libiconv.dylib and Libzbar.a (pictured)

And then introduce header files where you use them.

#import "ZBarSDK.h"

The class calling Zbar must implement the Zbarreaderdelegate protocol

such as: Uiviewcontroller <ZBarReaderDelegate> in-(void) Imagepickercontroller: (uiimagepickercontroller*) reader

Didfinishpickingmediawithinfo: (nsdictionary*) Info

Finally, the result value is obtained by info in the protocol method.

id<nsfastenumeration> results = [info objectforkey:zbarreadercontrollerresults]; 
Zbarsymbol *symbol = nil; 
for (symbol in results) 
//Example:just Grab the "the" I barcode break  
; 


Example:do something useful with the barcode data  
resulttext.text = Symbol.data; 
[CPP] View plaincopy
id<nsfastenumeration> results = [info objectforkey:zbarreadercontrollerresults]; 
Zbarsymbol *symbol = nil; 
for (symbol in results) 
//Example:just Grab the "the" I barcode break 
;  
Example:do something useful with the barcode data 
resulttext.text = Symbol.data; 

Document Address http://zbar.sourceforge.net/iphone/sdkdoc/
Two-dimensional code open Source Library zxing loading process is similar to this, but zxing default does not support one-dimensional code scanning, and Zbar is supported.

2. Generate a two-dimensional code (code)

Qrencoder is easier to use in a library that generates two-dimensional code. The Android version of the Zxing library is with the Java version of the code library, but I do not know why there is no C + + version of the decoder library, so there is no way to decode iOS, if the application must generate two-dimensional code and scan two-dimensional code may have to take two sets of different libraries.

The first is also downloaded to the SDK library in GitHub

Address Https://github.com/jverkoey/ObjQREncoder

After decompression, the source library is included directly into the project (figure)

Sets the header file path, building Settingssearch path in target

Of course, you can directly compile the library into a static library LIBQRECODER.A

And then in the inclusion in

Then add a reference to the static library in frameworks

Then include the header file where you use the library

#import <QREncoder/QREncoder.h>

Note: The two-dimensional code display may be due to the size of the image can be adjusted, so need to include system library Quartzcore.framework

Finally, you can call the code library:

uiimage* image = [Qrencoder encode:@ "http://www.baidu.com/"]; 

uiimage* image = [Qrencoder encode:@ "http://www.baidu.com/"]; 

The above content is to teach everybody how to use the two-dimensional code on Iphon iOS device, hope everybody likes.

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.