Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kingsic committed Jul 16, 2022
1 parent 5b4fa79 commit 41f0640
Show file tree
Hide file tree
Showing 37 changed files with 136 additions and 140 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

`扫描二维码`<br>

`手动对焦功能`<br>
`捕获内容缩放功能`<br>

`图片中识别二维码`<br>

Expand All @@ -34,7 +34,7 @@
| 类名 | 说明 |
|-----|-----|
| SGScanCode | 扫描二维码 |
| SGScanViewConfigure | 扫描视图属性配置 |
| SGScanViewConfigure | 扫描视图配置 |
| SGScanView | 扫描视图 |
| SGPermission | 相册、相机权限管理 |
| SGTorch | 手电筒管理 |
Expand All @@ -49,7 +49,7 @@

**通过 CocoaPods 集成**

`pod 'SGQRCode', '~> 4.0.0'`
`pod 'SGQRCode', '~> 4.1.0'`


**Info.plist 添加以下字段**
Expand Down Expand Up @@ -98,14 +98,14 @@ scanCode.sampleBufferDelegate = self;
}
```

**图片中识别二维码代码**
**图片中识别二维码方法**
```Objective-C
[scanCode readQRCode:image completion:^(NSString *result) {
<#code#>
}];
```
**生成二维码相关代码**
**生成二维码相关方法**
```Objective-C
// 普通二维码生成方法
[SGGenerateQRCode generateQRCodeWithData:data size:size];
Expand Down Expand Up @@ -135,6 +135,8 @@ scanCode.sampleBufferDelegate = self;

* 2022-07-16 :v4.0.0 版本重构:Delegate 取代 Block,新增手动对焦功能,优化拓展扫描视图,更多内容请在 [releases](https://github.com/kingsic/SGQRCode/releases/tag/4.0.0) 中查看

* 2022-07-16 :v4.1.0 优化SGScanView内部代码逻辑,修复无扫描线时,导致程序崩溃问题


## License
SGQRCode is released under the Apache License 2.0. See [LICENSE](https://github.com/kingsic/SGQRCode/blob/master/LICENSE) for details.
2 changes: 1 addition & 1 deletion SGQRCode.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = 'SGQRCode'
s.version = '4.0.0'
s.version = '4.1.0'
s.summary = 'The easy to use bar code and QR code scan library for iOS'
s.homepage = 'https://github.com/kingsic/SGQRCode'
s.license = 'Apache-2.0'
Expand Down
22 changes: 0 additions & 22 deletions SGQRCode/Category/UIImage+SGQRCode.h

This file was deleted.

27 changes: 0 additions & 27 deletions SGQRCode/Category/UIImage+SGQRCode.m

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,28 @@
// Copyright © 2022 kingsic. All rights reserved.
//

#import "SGPermissionEnum.h"
#import <Foundation/Foundation.h>

@class SGPermission;

typedef enum : NSUInteger {
/// 相机
SGPermissionTypeCamera,
/// 相册
SGPermissionTypePhoto,
} SGPermissionType;

typedef enum : NSUInteger {
/// 未授权
SGPermissionStatusNotDetermined,
/// 已授权
SGPermissionStatusAuthorized,
/// 已拒绝
SGPermissionStatusDenied,
/// 受限制
SGPermissionStatusRestricted,
} SGPermissionStatus;

NS_ASSUME_NONNULL_BEGIN

typedef void(^SGPermissionBlock)(SGPermission *permission, SGPermissionStatus status);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// Copyright © 2022 kingsic. All rights reserved.
//

#import "SGPermissionEnum.h"
#import <Foundation/Foundation.h>
#import "SGPermission.h"

@class SGPermissionCamera;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// Copyright © 2022 kingsic. All rights reserved.
//

#import "SGPermissionEnum.h"
#import <Foundation/Foundation.h>
#import "SGPermission.h"

@class SGPermissionPhoto;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions SGQRCode/SGScanCode.h → SGQRCode/QRCode/SGScanCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/// @param completion 回调方法,读取成功时,回调参数 result 等于二维码数据,否则等于 nil
- (void)readQRCode:(UIImage *)image completion:(void (^)(NSString *result))completion;

/// 设置焦距大小(焦距拉近放大
/// 设置视频缩放因子(捕获内容
- (void)setVideoZoomFactor:(CGFloat)factor;

/// 检测后置摄像头是否可用
Expand All @@ -44,6 +44,6 @@
- (void)stopRunning;

/// 播放音效
- (void)playSoundName:(NSString *)name;
- (void)playSoundEffect:(NSString *)name;

@end
2 changes: 1 addition & 1 deletion SGQRCode/SGScanCode.m → SGQRCode/QRCode/SGScanCode.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ - (void)stopRunning {
}
}

- (void)playSoundName:(NSString *)name {
- (void)playSoundEffect:(NSString *)name {
/// 静态库 path 的获取
NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:nil];
if (!path) {
Expand Down
File renamed without changes.
27 changes: 0 additions & 27 deletions SGQRCode/SGPermission/SGPermissionEnum.h

This file was deleted.

4 changes: 1 addition & 3 deletions SGQRCode/SGQRCode.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// SGQRCode.h
// Version 4.0.0
// Version 4.1.0
// https://github.com/kingsic/SGQRCode
//
// Created by kingsic on 2016/8/16.
Expand All @@ -14,8 +14,6 @@
#import "SGScanView.h"
#import "SGScanViewConfigure.h"
#import "SGPermission.h"
#import "SGPermissionEnum.h"
#import "SGSoundEffect.h"
#import "SGTorch.h"
#import "SGWeakProxy.h"
#import "UIImage+SGQRCode.h"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ - (UIImageView *)scanlineImgView {
}
_scanlineImgView.image = image;

[self updateScanLineFrame];
if (image) {
[self updateScanLineFrame];
}
}
return _scanlineImgView;
}
Expand Down Expand Up @@ -256,7 +258,9 @@ - (void)setScanFrame:(CGRect)scanFrame {

self.contentView.frame = scanFrame;

[self updateScanLineFrame];
if (self.scanlineImgView.image) {
[self updateScanLineFrame];
}
}

- (void)updateScanLineFrame {
Expand All @@ -268,6 +272,10 @@ - (void)updateScanLineFrame {
}

- (void)startScanning {
if (self.scanlineImgView.image == nil) {
return;
}

[self.contentView addSubview:self.scanlineImgView];

if (self.link == nil) {
Expand All @@ -277,6 +285,15 @@ - (void)startScanning {
}

- (void)stopScanning {
if (self.scanlineImgView.image == nil) {
return;
}

// 此代码防止由于外界逻辑,可能会导致多次停止
if (self.link == nil) {
return;
}

[self.scanlineImgView removeFromSuperview];
self.scanlineImgView = nil;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ + (instancetype)configure {

- (NSString *)scanline {
if (!_scanline) {
return @"SGQRCode.bundle/scan_scanline_wc";
return @"scan_scanline_wc";
}
return _scanline;
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 41f0640

Please sign in to comment.