Use ZBARSDK for iOS to scan QR codes and barcode functions

Source: Internet
Author: User
Tags uikit camerasim

1, to download zbarsdk.

2. Create your iOS Project.


3. Import ZBARSDK, drag the zbarsdk you downloaded to your project directly, and select the Copy option.

4. Add the following framework

5. Add the following methods to the Appdelegate file as follows:

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions{     // Your code    class ];     return YES;}

6. In the ViewController.h file you need to use the scan function, Add the following:

#import <UIKit/UIKit.h>"ZBarSDK.h"@interface Scanviewcontroller: Uiviewcontroller<ZBarReaderViewDelegate>{    *readerview;     **readerview; @end

7. In the viewcontroller.m file you need to use the scan function, Add the following:

#import"ScanViewController.h"@interface Scanviewcontroller () @end @implementation scanviewcontroller@synthesize Readerview;- (void) viewdidload{[Super Viewdidload]; //Your codeReaderview.readerdelegate =Self ;    [Readerview Setallowspinchzoom:yes]; if(target_iphone_simulator) {Camerasim=[[Zbarcamerasimulator alloc] initwithviewcontroller:self]; Camerasim.readerview=Readerview; }}-(void) Viewdidappear: (BOOL) animated{[Readerview start];}-(void) Viewdiddisappear: (BOOL) animated{[Readerview stop];}-(void) Readerview: (Zbarreaderview *) Readerview didreadsymbols: (Zbarsymbolset *) symbols FromImage: (UIImage *) image{NSString*codedata =[[NSString alloc] init];;  for(Zbarsymbol *syminchsymbols) {CodeData=Sym.data;  Break; } Uialertview*alert = [[Uialertview alloc] Initwithtitle:@"Scan Results"Message:codedataDelegate: Self Cancelbuttontitle:@"OK"Otherbuttontitles:nil, nil]; [Alert show];}-(void) Imagepickercontroller: (Uiimagepickercontroller *) Picker Didfinishpickingmediawithinfo: (NSDictionary *) info{//Get Barcode Resultsid<nsfastenumeration> results =[Info objectforkey:zbarreadercontrollerresults]; Zbarsymbol*symbol =Nil;  for(symbolinchresults) Break; //Get to Barcode//NSString *datanum=symbol.data; //Scan Interface Exit[Picker dismissmodalviewcontrolleranimated:yes];}

Use ZBARSDK for iOS to scan QR codes and barcode functions

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.