ios 二維碼掃描

來源:互聯網
上載者:User

標籤:

我是用ZBar做的二維碼掃描 其他的SDK也可以

首先是匯入庫檔案:

1.AVFoundation.framework

2.CoreMedia.framework

3.CoreVideo.framework

4.QuartzCore.framework

5.libiconv.dylib

這個5個庫檔案

在ViewController.h 匯入#import "ZBarSDK.h" 並且 繼承 <ZBarReaderDelegate>協議

123 @interface ViewController : UIViewController <zbarreaderdelegate> <br>@property (weak, nonatomicIBOutlet UIImageView *imageView;- (IBAction)scan:(id)sender;@property (weak, nonatomicIBOutlet UILabel *label;

  

UIImageView/UILabel/UIButton, UIImageView 用於顯示掃描到的映像,UILabel用於顯示掃描到的資訊,UIButton 用於響應事件

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;          [self presentViewController:reader animated:YES completion: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:YES completion:nil];          _label.text = symbol.data;}

ios 二維碼掃描

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.