ios实现条形码扫描功能
2012-04-05 14:47
477 查看
免费的条形码是zbar,其使用地址是:http://zbar.sourceforge.net/iphone/sdkdoc/install.html
下面是实现的效果:
利用条形码,可以简单的得到二维码的值.
具体的实现过程如下:
首先下载zbr的sdk。
然后,创建工程,iphone.scanbar。
第三,把下载的ZBarSDK添加到工程中。
第四,然后添加.framework到工程中。
下面是实现的效果:
利用条形码,可以简单的得到二维码的值.
具体的实现过程如下:
首先下载zbr的sdk。
然后,创建工程,iphone.scanbar。
第三,把下载的ZBarSDK添加到工程中。
第四,然后添加.framework到工程中。
-(void)buttonAction:(UIButton *)btn{ 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]; [reader release]; } - (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info { NSLog(@"info=%@",info); NSLog(@"info is a -------------->%@",info); // 得到条形码结果 id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults]; ZBarSymbol *symbol = nil; for(symbol in results) // EXAMPLE: just grab the first barcode break; // 将获得到条形码显示到我们的界面上 NSString *str = symbol.data; // 扫描时的图片显示到我们的界面上 NSLog(@"str is a -------------->%@",str); if([str hasPrefix:@"http"]){ NSURL *url = [NSURL URLWithString:str]; [[UIApplication sharedApplication] openURL:url]; }else if([str hasPrefix:@"localhost:"]){ NSString * categoryId = [str substringFromIndex:9]; NSDictionary *dic = [NSDictionary dictionaryWithObject:categoryId forKey:@"categoryId"]; [[NSNotificationCenter defaultCenter] postNotificationName:@"goIntoMgzViewNotification" object:self userInfo:dic]; }else{ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"二维码错误,请更换二维码后重试" delegate:self cancelButtonTitle:@"我知道了" otherButtonTitles:nil, nil] ; [alert show]; [alert release]; alert = nil; } // resultImage.image = [info objectForKey: UIImagePickerControllerOriginalImage]; // 扫描界面退出 [reader dismissModalViewControllerAnimated: YES]; }
相关文章推荐
- iOS 应用实现条形码扫描功能的方法
- iOS之使用ZbarSDK实现扫描二维码以及条形码功能
- 使用ZbarSDK实现扫描二维码以及条形码功能(iOS)
- ios实现条形码扫描功能
- iOS 应用实现条形码扫描功能的方法
- [IPHONE] iOS使用ZbarSDK实现扫描二维码以及条形码功能
- ios实现条形码扫描功能
- ios实现条形码扫描功能
- iOS 应用实现条形码扫描功能的方法
- iOS 应用实现条形码扫描功能的方法
- iOS 应用实现条形码扫描功能的方法
- ios实现条形码扫描功能
- iOS 应用实现条形码扫描功能的方法
- iOS 原生实现扫描二维码和条形码功能限制扫描区域
- 使用AVFoundation实现iOS原生二维码、条形码扫描(可限制扫描范围、可手动调节焦距)
- iOS实现二维码的扫描功能
- 实用知识:实现扫描二维码和条形码功能
- iOS开发之扫描二维码功能的实现
- iOS开发:使用苹果自带框架实现二维码和条形码扫描