Giter VIP home page Giter VIP logo

lxdscanqrcode's Introduction

LXDScanQRCode

对原生二维码扫描功能进行封装,轻松使用二维码扫描功能

相关类

LXDScanCodeController 扫描控制器,跳转后进入扫描,扫描成功后自动返回
LXDScanView 扫描视图,扫描成功后自动消失

扫描成功回调

提供了代理和通知两种回调方式,通知只在代理人未实现回调方法的情况下发送通知
LXDScanCodeController 通过LXDScanCodeControllerDelegate代理回调
LXDScanView 通过代理LXDScanViewDelegate回调、通过发送LXDSuccessScanQRCodeNotification通知回调

代理方式 - 通过LXDScanCodeControllerDelegate代理回调
- (void)scanCodeController:(LXDScanCodeController *)scanCodeController codeInfo:(NSString *)codeInfo {
NSURL * url = [NSURL URLWithString: codeInfo];
if ([[UIApplication sharedApplication] canOpenURL: url]) {
[[UIApplication sharedApplication] openURL: url];
} else {
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle: @"警告" message: [NSString stringWithFormat: @"%@:%@", @"无法解析的二维码", codeInfo] delegate: nil cancelButtonTitle: @"确定" otherButtonTitles: nil];
[alertView show];
}
}

代理方式 - 通过代理LXDScanViewDelegate回调
- (void)scanView:(LXDScanView *)scanView codeInfo:(NSString *)codeInfo {
NSURL * url = [NSURL URLWithString: codeInfo];
if ([[UIApplication sharedApplication] canOpenURL: url]) {
[[UIApplication sharedApplication] openURL: url];
} else {
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle: @"警告" message: [NSString stringWithFormat: @"%@:%@", @"无法解析的二维码", codeInfo] delegate: nil cancelButtonTitle: @"确定" otherButtonTitles: nil];
[alertView show];
}
}

通知方式
- (void)receiveScanQRCodeNotification: (NSNotification *)notification {
NSString * codeInfo = [notification.userInfo valueForKey: LXDScanQRCodeMessageKey];
NSURL * url = [NSURL URLWithString: codeInfo];
if ([[UIApplication sharedApplication] canOpenURL: url]) {
[[UIApplication sharedApplication] openURL: url];
} else {
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle: @"警告" message: [NSString stringWithFormat: @"%@:%@", @"无法解析的二维码", codeInfo] delegate: nil cancelButtonTitle: @"确定" otherButtonTitles: nil];
[alertView show];
}
}

控件使用

控制器跳转
LXDScanCodeController * scanCodeController = [LXDScanCodeController scanCodeController];
scanCodeController.scanDelegate = self;
[self.navigationController pushViewController: scanCodeController animated: YES];

扫描视图使用
LXDScanView * scanView = [LXDScanView scanViewShowInController: self];
scanView.delegate = self;
[self.view addSubview: scanView];
[scanView show];

lxdscanqrcode's People

Contributors

sindrilin avatar

Watchers

James Cloos avatar Harold Bierlein avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.