ZBarSDK扫描二维码

1:如果报引用文件错误的话需要在设置一下:project->Build settings->build active architecture only选项设置为No。Valid Architecture 选项设置为armv7.

#import "ViewController.h"
#import "ZBarSDK.h"


@interface ViewController ()<ZBarReaderDelegate>
@property (weak, nonatomic) IBOutlet UIImageView *myImageView;
@property (weak, nonatomic) IBOutlet UILabel *descLabel;

@end

@implementation ViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
   
    
    
}
- (IBAction)scanBtnClick:(UIButton *)sender
{
    ZBarReaderViewController *reader=[ZBarReaderViewController new];
    reader.readerDelegate=self;
    ZBarImageScanner *scaner=reader.scanner;
    [scaner 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)
    {
        _myImageView.image=[info objectForKey:UIImagePickerControllerOriginalImage];
        [picker dismissViewControllerAnimated:YES completion:nil];
        _descLabel.text=symbol.data;
    }
}
@end

 

posted @ 2015-02-09 15:09  曹县三胖暴打大猩猩  阅读(229)  评论(0编辑  收藏  举报