CDZQRScanningViewController 1.0.7

CDZQRScanningViewController 1.0.7

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新版本2014年12月

Chris Dzombak 维护。



  • 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。

为什么使用这个而不是 ZBarSDK?

  • 更小的Surface Area
  • 更容易使用
  • 配置更少
  • 对代码影响更小
  • 由于其全新的 iOS 7 API,尺寸更小
  • MIT 许可证而非 GPL

需求

CDZQRScanningViewController 需要iOS 7+。

许可证

MIT。请参阅此仓库中包含的 LICENSE

开发者

Chris Dzombak