ios 二维码生成 扫瞄
// // ViewController.m // ZBarDemo // // Created by qingyun on 4/9/13. // Copyright (c) 2013 qingyun. All rights reserved. // #import "ViewController.h" #import "QRCodeGenerator.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; _inputText.delegate = self; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults]; ZBarSymbol *symbol = nil; for(symbol in results) break; _backImageView.image = [info objectForKey: UIImagePickerControllerOriginalImage]; [picker dismissModalViewControllerAnimated: YES]; _label.text = symbol.data ; } - (void)dealloc { [_inputText release]; [_backImageView release]; [_label release]; [super dealloc]; } - (IBAction)btnPress:(id)sender { _backImageView.image = [QRCodeGenerator qrImageForString:_inputText.text imageSize:_backImageView.bounds.size.width]; } - (IBAction)saoMiaoBtnPress:(id)sender { ZBarReaderViewController *reader = [ZBarReaderViewController new]; reader.readerDelegate = self; reader.supportedOrientationsMask = ZBarOrientationMaskAll; ZBarImageScanner *scanner = reader.scanner; [scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to: 0]; [self presentModalViewController: reader animated: YES]; [reader release]; } -(BOOL)textFieldShouldReturn:(UITextField *)textField { [_inputText resignFirstResponder]; return YES; } @end
demo 地址:http://115.com/18120767