Zac*_*c24 1 iphone qr-code objective-c zxing ios
我正在开发一个应用程序,其中我需要添加QR代码阅读器功能,这应该是这样的事情,我需要在主页上有一个图标,并通过单击该图标QR reader应该工作.我用谷歌搜索它,发现ZBarCoderReader很好用,但我陷入了整合这个SDK的困境.任何人都可以帮助集成此SDK.我知道我必须使用以下链接来集成此SDK.
http://zbar.sourceforge.net/iphone/sdkdoc/install.html
http://zbar.sourceforge.net/iphone/sdkdoc/camera.html
任何帮助将不胜感激.
dmg并将ZBarSDK文件夹复制到您的文件夹中project directory.ZBarSDK framework.Build Phases并展开Link Binary With Libraries并添加以下附加框架
然后
导入头文件
#import "ZBarSDK.h"
Run Code Online (Sandbox Code Playgroud)
在图标按钮的触摸上添加以下代码:
- (IBAction)iconButtonTouchEvent:(id)sender {
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
//Hide Info Button at Right bottom and Show only Cancel Button at Left Bottom
float currentVersion= 5.1;
float sysVersion = [[[UIDevice currentDevice]systemVersion]floatValue];
UIView * infoButton;
if (sysVersion > currentVersion) {
infoButton = [[[[[reader.view.subviews objectAtIndex:1] subviews] objectAtIndex:0] subviews] objectAtIndex:3];
}
else {
infoButton = [[[[[reader.view.subviews objectAtIndex:1] subviews] objectAtIndex:0] subviews] objectAtIndex:2];
}
[infoButton setHidden:YES];
ZBarImageScanner *scanner = reader.scanner;
[scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to: 0];
[self presentModalViewController: reader animated: YES];
}
#pragma mark - Barcode Delegate Methods
- (void)imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info{
id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for(symbol in results)
break;
NSLog(@"Barcode Data = %@", symbol.data);
[reader dismissModalViewControllerAnimated: YES];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4126 次 |
| 最近记录: |