A moment to download
Project Address:
Https://github.com/yannickl/QRCodeReaderViewController
The official introduction of the QRCode can specify the encoding, especially it supports ios7+, which can be used to replace zxing, Zbar. I started using Zbar at the beginning of the project, and normally it was normal, but when scanning a very small QR code, it was not recognized. After switching to QRCode, the recognition effect is quite good.
It will provide a default view controller call camera and will provide a button to toggle the front camera and rear camera.
This is the official screenshot:
The recommended installation method for installation is to use the Cocoapods package management tool. In the Podfile file, enter:
$CD/path/to/myproject$ Touch podfile$ Vim PodfileSource 'https://github.com/CocoaPods/Specs.git' Platform:ios, '7.0' Pod 'qrcodereaderviewcontroller' , '~> 3.4.0'
Then execute on the command line: Pod Install
After you wait for the installation to finish, enter open ****.xcworkspace.
Using the header file:
viewcontroller.h// smarthome//// Created by Xie Han Festival on 15/5/14.// Copyright (c) 2015 WHR. All rights reserved.//#import <UIKit/UIKit.h> #import "QRCodeReaderViewController.h" @interface Viewcontroller: Uiviewcontroller<qrcodereaderdelegate> @end
. m File:
#import "QRCodeReaderViewController.h"
-(void) actionscan{nsarray *types = @[avmetadataobjecttypeqrcode]; qrcodereaderviewcontroller* _reader = [Qrcodereaderviewcontroller readerwithmetadataobjecttypes:types]; Set the presentation style _reader.modalpresentationstyle = Uimodalpresentationformsheet; Using delegate methods _reader.delegate = self; Or by using blocks [_reader setcompletionwithblock:^ (NSString *resultasstring) {[Self Dismissviewcontrollera Nimated:yes completion:^{NSLog (@ "%@", resultasstring); }]; }]; [Self Presentviewcontroller:_reader animated:yes completion:null];} #pragma mark-qrcodereader Delegate methods-(void) Reader: (Qrcodereaderviewcontroller *) Reader Didscanresult: ( NSString *) result{[self dismissviewcontrolleranimated:yes completion:^{NSLog (@ "%@", result); }];} -(void) Readerdidcancel: (Qrcodereaderviewcontroller *) reader{[self dismissviewcontrolleranimated:yes completion: NULL];}When installing with cocoapods, there may be errors in compiling, and you need to modify the settings of the pods target: there is another way, I did not look closely. Put it here for reference: http://cameronspickert.com/2014/01/20/remove-the-arm64-architecture-from-cocoapods-targets.html
IOS8 Two-dimensional code scanning-qrcodereaderviewcontroller