ios 二维码扫描和生成
来源:互联网 发布:php内容管理系统 编辑:程序博客网 时间:2024/05/19 02:04
转自https://github.com/kingsic/SGQRCode
#import "SGQRCodeTool.h"//生成二维码
#import "SGQRCode.h"//扫描二维码
UIImageView *imageView2;
//生成二维码
imageView2 = [[UIImageView alloc]initWithFrame:CGRectMake(kViewWidth / 2 +50, kViewHeight / 2 +50, 50, 50)];
imageView2.image = [SGQRCodeTool SG_generateWithDefaultQRCodeData:@"https://github.com/kingsic" imageViewWidth:50];
[self.view addSubview:imageView2];
//二维码识别
将demo中的QRCodeScanningVC和ScanSuccessJumpVC复制进项目
#import "QRCodeScanningVC.h"
-(void)scanningQRCode{
// 1、 获取摄像设备
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if (device) {
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if (status == AVAuthorizationStatusNotDetermined) {
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
if (granted) {
dispatch_async(dispatch_get_main_queue(), ^{
QRCodeScanningVC *vc = [[QRCodeScanningVC alloc] init];
[self.navigationController pushViewController:vc animated:YES];
});
SGQRCodeLog(@"当前线程 - - %@", [NSThread currentThread]);
// 用户第一次同意了访问相机权限
SGQRCodeLog(@"用户第一次同意了访问相机权限");
} else {
// 用户第一次拒绝了访问相机权限
SGQRCodeLog(@"用户第一次拒绝了访问相机权限");
}
}];
} else if (status == AVAuthorizationStatusAuthorized) { // 用户允许当前应用访问相机
QRCodeScanningVC *vc = [[QRCodeScanningVC alloc] init];
[self.navigationController pushViewController:vc animated:YES];
} else if (status == AVAuthorizationStatusDenied) { // 用户拒绝当前应用访问相机
UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"⚠️ 警告" message:@"请去-> [设置 - 隐私 - 相机 - SGQRCodeExample] 打开访问开关" preferredStyle:(UIAlertControllerStyleAlert)];
UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
}];
[alertC addAction:alertA];
[self presentViewController:alertC animated:YES completion:nil];
} else if (status == AVAuthorizationStatusRestricted) {
NSLog(@"因为系统原因, 无法访问相册");
}
} else {
UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"未检测到您的摄像头" preferredStyle:(UIAlertControllerStyleAlert)];
UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
}];
[alertC addAction:alertA];
[self presentViewController:alertC animated:YES completion:nil];
}
}
- ios二维码生成和扫描
- iOS 二维码生成和扫描
- ios 二维码扫描和生成
- iOS自带扫描 和 生成二维码
- iOS 二维码的生成和扫描
- iOS自带扫描 和 生成二维码
- iOS平台 二维码生成和扫描
- iOS--二维码生成和扫描
- iOS自带扫描 和 生成二维码
- iOS自带扫描 和 生成二维码
- ios 原生二维码的扫描和生成
- iOS自带扫描和生成二维码
- iOS开发二维码生成和扫描
- iOS开发 二维码扫描和生成
- IOS 中实现自定义扫描二维码和生成二维码
- ios 开发之 扫描二维码和生成二维码
- 二维码生成和二维码扫描
- 扫描二维码和生成二维码
- Android 实现ListView的A-Z字母排序和过滤搜索功能,实现汉字转成拼音
- Powershell 操作SQL Server
- struts2__Action配置的各项默认值
- 你绝对想知道:芝麻信用新域名xin.xin是个什么鬼!
- Android的js与java交互
- ios 二维码扫描和生成
- 链栈
- iOS开发
- PHP create_function()代码注入 (执行脚本函数)
- SQL——后台分页(C#,mysql)
- adb调试命令
- leetcode-第十三周
- 算法实例
- redis的配置以及简单使用