Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting ZXing to a button in xcode

I am new to programming, so this question I'm sure is extremely basic (bear with me!)

I just installed zxing into my current xcode 4.5 project. It took me a while to get through the errors, but I finally got it.

I created a button called "scan" where I want zxing to be called. How can I make this happen?

I've tried looking at the files I implemented into my source files but cannot figure out which classes and method to use.

And yes, I tried a google search on this extremely basic concept but found nothing :(

like image 664
Adam Avatar asked Dec 19 '12 02:12

Adam


1 Answers

Here is the code you need to add in your scan button action.

- (IBAction)scanPressed:(id)sender
 {

            ZXingWidgetController *widController = [[ZXingWidgetController alloc]  initWithDelegate:self showCancel:YES OneDMode:NO];

            NSMutableSet *readers = [[NSMutableSet alloc ] init];

            <#if ZXQR>

                QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init];
                [readers addObject:qrcodeReader];

           <#endif>

           <#if ZXAZ>
                AztecReader *aztecReader = [[AztecReader alloc] init];
                [readers addObject:aztecReader];

           <#endif>

                widController.readers = readers;

                [self presentModalViewController:widController animated:YES];

}

remove the "<>" signs before use this code in your app.

like image 126
Abhishek Avatar answered Oct 22 '22 14:10

Abhishek