http://blog.csdn.net/abcmx/article/details/8011904
Now the two-dimensional code everywhere, whether it is physical goods or a variety of vouchers are the two-dimensional code of the figure. Mobile devices, such as mobile phones, have become a good application platform for QR codes, whether it is to generate QR codes or QR codes.
Here's how to use the QR code on an Apple iOS device:
1. Scan QR code (decode)
Scanning the two-dimensional code of open Source Library has many such as Zbar, zxing and so on. In this zbar as an example to build QR code scanning code application.
First download the Zbar SDK on GitHub
Address Https://github.com/bmorton/ZBarSDK
Open the compressed package, which has the Zbarsdk folder
Include the Zbarsdk folder in your project to
(Finder)
(XCode)
which contains a static library of LIBZBAR.A
Then add the framework framework and the link library (dynamic library, Static library) to the project. In the project properties targets? Linked frameworks and Libraries found in Summary
Add to
Avfoundation.framwork, Coremedia.framework, Corevideo.framework, Libiconv.dylib and Libzbar.a ()
Then introduce the header file where it is used
#import "ZBarSDK.h"
Classes that call Zbar must implement the Zbarreaderdelegate protocol
such as: Uiviewcontroller <ZBarReaderDelegate>
In-(void) Imagepickercontroller: (uiimagepickercontroller*) reader
Didfinishpickingmediawithinfo: (nsdictionary*) Info
Finally, the result value is obtained through info in the protocol method.
[CPP]View Plaincopy < param name= "wmode" value= "Transparent" >
- id<nsfastenumeration> results = [info objectforkey:zbarreadercontrollerresults];
- Zbarsymbol *symbol = nil;
- for (symbol in results)
- Example:just Grab the first barcode
- Break
- Example:do something useful with the barcode data
- Resulttext.text = Symbol.data;
[CPP]View Plaincopy < param name= "wmode" value= "Transparent" >
- id<nsfastenumeration> results = [info objectforkey: zbarreadercontrollerresults];
- zbarsymbol *symbol = nil;
- for (symbol in results)
- // example: just grab the first barcode
- break;
-
- // example: do something useful with the barcode data
- resulttext.text = symbol.data;
Document Address http://zbar.sourceforge.net/iphone/sdkdoc/
QR Code Open Source Library The zxing process is similar, but zxing does not support scanning of one-dimensional code by default, and Zbar is supported.
2. Generate two-dimensional code (encoding)
In the generation of two-dimensional code of the library Qrencoder more useful. The Android version of the Zxing library is a Java version of the code library, but I do not know why there is no C + + version of the decoding library, it can not be decoded on iOS, if the application is to generate two-dimensional code and scan the QR code is likely to take two sets of different libraries.
The first is also downloaded to the SDK library on GitHub
Address Https://github.com/jverkoey/ObjQREncoder
The source library is included directly into the project after decompression ()
Set the header file path, building settings in target? Search Path
Of course, you can compile the library directly into a static library libqrecoder.a and then include it in the
Then add a reference to the static library in the frameworks
Then include the header file where the library is used
#import <QREncoder/QREncoder.h>
Note: The QR code display may be adjusted for the size of the image, so it is necessary to include the system library Quartzcore.framework
Finally, you can call the encoding library:
[CPP]View Plaincopy
- uiimage* image = [Qrencoder encode:@"http://www.baidu.com/"];
[CPP]View Plaincopy
- uiimage* image = [Qrencoder encode:@"http://www.baidu.com/"];
Implement QR code functionality on iOS