【iOS QR Code】集成ZXingWidget(XCode Version 4.5.2,iOS 6.0 SDK)
2013-06-17 15:11
741 查看
【iOS QR Code】集成ZXingWidget(XCode Version 4.5.2,iOS 6.0 SDK)
1、添加ZXingWidget打开目录ZXing/iphone/ZXingWidget,将ZXingWidget.xcode文件拖拽添加到项目中
2、设置Link Binary With Libraries
TARGETS -> Build Phases -> Link Binary With Libraries
点击+,添加libZXingWidget.a
3、设置Target Dependencies
TARGETS -> Build Phases -> Target Dependencies
点击+,添加ZXingWidget
4、设置Header Search Paths
TARGET -> Build Settings -> Search Paths -> Header Search Paths
添加ZXing/iphone/ZXingWidget/Classes相对路径,选择recursive
添加ZXing/cpp/core/src相对路径,选择non-recursive
5、导入iOS框架
TARGETS -> Build Phases -> Link Binary With Libraries
点击+,添加***Foundation、AudioToolbox、CoreVideo、CoreMedia、libiconv、AddressBook和AddressBookUI
6、测试
ViewController.h
#import <UIKit/UIKit.h> #import <ZXingWidgetController.h> #import <QRCodeReader.h> @interface ViewController : UIViewController <ZXingDelegate> - (IBAction)scan:(id)sender; @end
将ViewController.m重命名为ViewController.mm
#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)scan:(id)sender { ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO]; QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init]; NSSet *readers = [[NSSet alloc ] initWithObjects:qrcodeReader,nil]; [qrcodeReader release]; widController.readers = readers; [readers release]; NSBundle *mainBundle = [NSBundle mainBundle]; widController.soundToPlay = [NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"aiff"] isDirectory:NO]; [self presentModalViewController:widController animated:YES]; [widController release]; } #pragma mark - #pragma mark ZXingDelegate - (void)zxingController:(ZXingWidgetController *)controller didScanResult:(NSString *)result { [self dismissModalViewControllerAnimated:YES]; UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"结果" message:result delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; [alertView show]; [alertView release]; } - (void)zxingControllerDidCancel:(ZXingWidgetController *)controller { [self dismissModalViewControllerAnimated:YES]; } @end
相关文章推荐
- 【iOS QR Code】集成ZXingWidget(XCode Version 4.5.2,iOS 6.0 SDK)
- 【iOS QR Code】集成ZXingWidget(XCode Version 4.5.2,iOS 6.0 SDK)
- Ogre 1.8.0 iOS SDK and Ogre_iOS_6.0_Dependencies_20120912 and Ogre Templates for Xcode 4 3
- iOS xCode4.5.2兼容低版本sdk,如sdk4.2等。
- Original error: Could not get the iOS SDK version because the Xcode version could not be determined
- Installing iOS SDK and Xcode on Windows 7
- IOS中快速集成短信SDK验证开发(SMSSDK),IOS开发中如何设置手机短信验证码
- 集成支付宝钱包支付 iOS SDK 的方法与经验
- AR!!!高通Vuforia-iOS-SDK 和官方Demo 集成到iOS 项目中所需要注意的几点.
- 集成支付宝钱包支付iOS SDK的方法与经验
- iOS 判断并使用 百度地图 高德地图 自带地图 导航(使用URI,不集成sdk)
- iOS开发 - 友盟统计SDK集成(umsdk_IOS_analyics_no-idfa_v4.2.5)
- Xcode6.0后IOS7.0之后的手势滑动
- iOS学习笔记4-xcode构建iOS app时为什么分version和build两个版本号
- 关于iOS GangSDK的使用 为App快速集成社群公会模块
- JIL Widget SDK Version 1.0 Overview
- 使用 Xcodebuild + Jenkins + Apache 做 iOS 持续集成
- IOS zxing 集成
- 苹果发布Xcode 4.5 SDK 支持iOS 6和OS X 10.8 Mountain Lion
- xcode6.3加入iOS 7.1SdK后,iphone5s模拟器 屏幕高度只有480的问题