I'm using the Zbar QR code to scan the other SDK can also
The first is to import the library file:
1.avfoundation.framework
2.coremedia.framework
3.corevideo.framework
4.quartzcore.framework
5.libiconv.dylib
This 5 library file
Import #import "ZBarSDK.h" in ViewController.h and inherit <ZBarReaderDelegate> protocol
| 123 |
@interface viewcontroller:uiviewcontroller <zbarreaderdelegate> <br> @property (weak, Nonatomic iboutlet uiimageview *imageview; -( ibaction ) Scan: ( id @property (weak, nonatomic iboutlet uilabel *label; |
Uiimageview/uilabel/uibutton, Uiimageview used to display scanned images, UILabel used to display the information scanned, UIButton for responding to events
| 123456789101112131415161718192021222324252627282930 |
- (IBAction)scan:(id)sender { ZBarReaderViewController * reader = [ZBarReaderViewController new]; reader.readerDelegate = self; ZBarImageScanner * scanner = reader.scanner; [scanner setSymbology:ZBAR_I25 config:ZBAR_CFG_ENABLE to:0]; reader.showsZBarControls = YES; [selfpresentViewController:reader animated:YEScompletion:nil]; } -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary*)info{ id<nsfastenumeration> results = [info objectForKey:ZBarReaderControllerResults]; ZBarSymbol * symbol; for(symbol in results) break; _imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage]; [picker dismissViewControllerAnimated:YEScompletion:nil]; _label.text = symbol.data;} |
iOS QR code scan