How to add ZBar sdk in xcode for QRCode scanner / Barcode scanner?


For creating the QRCode scanner or Bar code scanner application in xcode you have to follow the following steps:

1) Create a new Project of xcode.

2) Add ZBar Sdk in your application.

3) Add following framework :

  • AVFoundation.framework
  • CoreVideo.framework
  • QuartzCore.framework
  • SystemConfiguration.framework
  • CoreMedia.framework
  • AudioToolbox.framework
  • UIKit.framework
  • Foundation.framework
  • CoreGraphics.framework

4) In first view controller of the project add text area for showing the output or result of scan Bar code or QRcode. Also add an image for scanning the code.

5) When you click on the scan button of view controller it will navigates you to the ZBar Sdk library.

// code for the navigation to the view controller to the ZBar Sdk library.

– (IBAction) scanButtonTapped
{
    
   
    ZBarReaderViewController *reader = [ZBarReaderViewController new];
    reader.readerDelegate = self;
    
    [reader.scanner setSymbology: ZBAR_UPCA config: ZBAR_CFG_ENABLE to: 0];
    reader.readerView.zoom = 1.0;
    
    [self presentModalViewController: reader
                            animated: YES];
    
}

After completing the scanning of the code it will make beep sound and shows the results. Add following code….

– (void) imagePickerController: (UIImagePickerController*) reader
 didFinishPickingMediaWithInfo: (NSDictionary*) info
{
    id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];
    
    ZBarSymbol *symbol = nil;
    
    for(symbol in results){
        
        NSString *upcString = symbol.data;

//Add beep.mp3 in your resource directory of project.
        NSString *path = [[NSBundle mainBundle] pathForResource:@”beep” ofType:@”mp3″];
        AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
        
        theAudio.delegate=self;
        [theAudio play];

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@”Scanned UPC” message:[NSString stringWithFormat:@”Successful UPC read.”] delegate:self cancelButtonTitle:nil otherButtonTitles:@”Ok”, nil];
        
        [alert show];
        
        resultText.text=upcString;
        
        [reader dismissModalViewControllerAnimated: YES];
        
    }
    
    
}
Hope it will make you cheers!!!!

Advertisements

22 thoughts on “How to add ZBar sdk in xcode for QRCode scanner / Barcode scanner?

  1. This is awesome information! Have you considered putting this content within a
    Pdf file and upload it on the internet or publish it as an e-book somehow?

  2. Hi, this is very useful for me. however, how can I show the website directly after the scanning of the code if the result is a url?

    • Hi , Yu Chang Li. I got answer of the query you asked. Yes its possible. First you scan the QRCode and then put the result in validation of a url. if its showing correct then put the url into the web browser. I hope you understand the procedure. If have problem then let me know.

      Waiting your response on the same.

  3. If you are paying attention to learn Web optimization techniques then you must read this paragraph, I am sure you will take much more from this paragraph on the topic of Web optimization.

  4. This information is worth everyone’s attention. How can I find out more?

  5. These all YouTube gaming video lessons are actually in good quality, I watched out all these along by my friends.

  6. Ahaa , il suo attraente discussione per quanto riguarda questo paragrafo qui a da questo blog , ho letto esaminare intero che , cos da periodo me anche commentando qui .

  7. Per le informazioni pi recenti si must visita rete e bordo fondo questo rete foglio per una migliore rete foglio per massimo aggiornamenti recenti.

  8. Ho ottenuto questo sito dal mio amico che ha condiviso con me per quanto riguarda questo sito e rapidamente periodo sto visitando questo sito e la lettura abbastanza alternativamente recensioni qui .

  9. Download di importa da questo sito for effortlesswebsites che mi trasferiscono qui e l bordo a bordo delle pagine Internet .

  10. All right, you are right buddy,aboard a customary basis updating webpage is really required among advocate of SEO. Nice contention keeps it up.

  11. What’s up, thanks for all the users, I aspiration increase many more movie clips among hereafter days, admin

  12. Today YouTube movie tutorials quality namely more improved and enhanced, so that the reason that I am watching this movie by by this space.

  13. Pingback: Scan QRCode or BarCode in iOS Application | MobileDesk

  14. Thanks Arun for writing such a great post.

  15. Attractiive part of content. I just stumbled upon your blog
    and in accession capital to assert that I get in fact enjoyed account yyour blog posts.
    Anyway I will bbe subscribing too your auggment and even I success you get rright of entry to consistently rapidly.

  16. If you petition these methods for increasing vehicle aboard your own webpage, I am obviously you ambition perceive the variation amid few days.

  17. Quality content is the important to invite the people to expenditure a visit the web site, that what this web site is providing.

  18. This post concerning how apt inlay a YouTube video code namely genuinely helpful amid advocate of fashionable internet way viewers. Good job,reserve it up.

  19. Link exchange namely nothing else except it namely impartial placing the other person blog link aboard your sheet at adapted area and other person aspiration also do similar among favor of you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s