zbar扫描二维码,条维码

下载ZbarSDK,导入framework:

AVFoundation.framework (weak)

CoreMedia.framework (weak)

CoreVideo.framework (weak)

QuartzCore.framework

libiconv.dylib

代码:

//实现
- (void) imagePickerController: (UIImagePickerController*) reader
 didFinishPickingMediaWithInfo: (NSDictionary*) info
{
    id<NSFastEnumeration> results =
    [info objectForKey: ZBarReaderControllerResults];
    ZBarSymbol *symbol = nil;
    for(symbol in results)
        break;
    NSLog(@"===%@",symbol.data);
    
    self.content.text = symbol.data;
    
    [reader dismissModalViewControllerAnimated: YES];[reader release];
}

- (IBAction)buttonChange:(id)sender {
    ZBarReaderViewController *reader = [ZBarReaderViewController new];
    reader.readerDelegate = self;
    ZBarImageScanner *scanner = reader.scanner;
    [scanner setSymbology: ZBAR_I25
                   config: ZBAR_CFG_ENABLE
                       to: 0];
    [self presentModalViewController: reader
                            animated: YES];
}


你可能感兴趣的:(zbar扫描二维码,条维码)