测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | MIT |
发布最新版本 | 2014年12月 |
由 Chris Dzombak 维护。
iOS 7 上的简易 QR 码扫描。
将依赖添加到您的 Podfile
。
platform :ios
pod 'CDZQRScanningViewController'
...
运行 pod install
以安装依赖。
#import "CDZQRScanningViewController.h"
,然后
// assume this text field is defined elsewhere:
UITextField *field = self.someTextField;
[field becomeFirstResponder];
// create the scanning view controller and a navigation controller in which to present it:
CDZQRScanningViewController *scanningVC = [CDZQRScanningViewController new];
UINavigationController *scanningNavVC = [[UINavigationController alloc] initWithRootViewController:scanningVC];
// configure the scanning view controller:
scanningVC.resultBlock = ^(NSString *result) {
field.text = result;
[scanningNavVC dismissViewControllerAnimated:YES completion:nil];
};
scanningVC.cancelBlock = ^() {
[scanningNavVC dismissViewControllerAnimated:YES completion:nil];
};
scanningVC.errorBlock = ^(NSError *error) {
// todo: show a UIAlertView orNSLog the error
[scanningNavVC dismissViewControllerAnimated:YES completion:nil];
};
// present the view controller full-screen on iPhone; in a form sheet on iPad:
scanningNavVC.modalPresentationStyle = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? UIModalPresentationFullScreen : UIModalPresentationFormSheet;
[self presentViewController:scanningNavVC animated:YES completion:nil];
如果您不想在自己的模态 UIViewController
中展示扫描器,请使用视图控制器包含来将其嵌入您自己的视图控制器,而不是像示例那样在导航控制器内展示它。
在实时视频视图中连续按住 0.25 秒以 activate the device's flashlight for use in low-light。
CDZQRScanningViewController
需要iOS 7+。
MIT。请参阅此仓库中包含的 LICENSE
。
Chris Dzombak