Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
abcmx-lbx committed Oct 12, 2020
1 parent fd652ea commit 3aa6961
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Source/LBXPermissions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class LBXPermissions: NSObject {
comletion(status == PHAuthorizationStatus.authorized)
}
})
case .limited:

This comment has been minimized.

Copy link
@AaronHu

AaronHu Oct 14, 2020

可以在这里添加版本check吗?这是iOS14新增的,Xcode11会编译错误

This comment has been minimized.

Copy link
@MichealNguyen1

MichealNguyen1 Oct 14, 2020

I am facing this issue now.
And change SWIFT_VERSION to 4.0 and remove QRRectDelegate for now.
Thank so much.

This comment has been minimized.

Copy link
@MichealNguyen1

MichealNguyen1 Oct 20, 2020

I changed my Podfile to:
pod 'swiftScan', '1.1.5'
and it's working perfectly. Hope it would help someone.

comletion(true)
@unknown default:
comletion(false)
}
Expand Down
14 changes: 13 additions & 1 deletion Source/LBXScanViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ open class LBXScanViewController: UIViewController {

// 启动区域识别功能
open var isOpenInterestRect = false

//连续扫码
open var isSupportContinuous = false;

// 识别码的类型
public var arrayCodeType: [AVMetadataObject.ObjectType]?
Expand Down Expand Up @@ -94,7 +97,11 @@ open class LBXScanViewController: UIViewController {
strongSelf.qRScanView?.stopScanAnimation()
strongSelf.handleCodeResult(arrayResult: arrayResult)
})


}

scanObj?.supportContinuous = isSupportContinuous;

// 结束相机等待提示
qRScanView?.deviceStopReadying()
Expand Down Expand Up @@ -123,7 +130,12 @@ open class LBXScanViewController: UIViewController {
guard let delegate = scanResultDelegate else {
fatalError("you must set scanResultDelegate or override this method without super keyword")
}
navigationController?.popViewController(animated: true)

if !isSupportContinuous {
navigationController?.popViewController(animated: true)

}

if let result = arrayResult.first {
delegate.scanFinished(scanResult: result, error: nil)
} else {
Expand Down
19 changes: 16 additions & 3 deletions Source/LBXScanWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ open class LBXScanWrapper: NSObject,AVCaptureMetadataOutputObjectsDelegate {
// 当前扫码结果是否处理
var isNeedScanResult = true

//连续扫码
var supportContinuous = false


/**
初始化设备
- parameter videoPreView: 视频显示UIView
Expand Down Expand Up @@ -173,16 +177,25 @@ open class LBXScanWrapper: NSObject,AVCaptureMetadataOutputObjectsDelegate {
guard let code = current as? AVMetadataMachineReadableCodeObject else {
continue
}

#if !targetEnvironment(simulator)

arrayResult.append(LBXScanResult(str: code.stringValue,
img: UIImage(),
barCodeType: code.type.rawValue,
corner: code.corners as [AnyObject]?))
#endif
}

if arrayResult.isEmpty {
if arrayResult.isEmpty || supportContinuous {
isNeedScanResult = true
} else {
if isNeedCaptureImage {
}
if !arrayResult.isEmpty {

if supportContinuous {
successBlock(arrayResult)
}
else if isNeedCaptureImage {
captureImage()
} else {
stop()
Expand Down
2 changes: 1 addition & 1 deletion swiftScan.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'swiftScan'
s.version = '1.2.0'
s.version = '1.2.1'
s.summary = 'ios swift scan wrapper'
s.homepage = 'https://github.com/MxABC/swiftScan'
s.license = 'MIT'
Expand Down
6 changes: 3 additions & 3 deletions swiftScan.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
TargetAttributes = {
7D42B9AB1C05EE9A0084D045 = {
CreatedOnToolsVersion = 7.1;
DevelopmentTeam = LM3HW8FY8K;
DevelopmentTeam = 8LQ7CL73D8;
LastSwiftMigration = 0820;
ProvisioningStyle = Automatic;
};
Expand Down Expand Up @@ -378,11 +378,11 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = LM3HW8FY8K;
DEVELOPMENT_TEAM = 8LQ7CL73D8;
INFOPLIST_FILE = swiftScan/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.51shaoxi.github.swiftScan;
PRODUCT_BUNDLE_IDENTIFIER = com.lbx.hk2019235;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "5afb03a3-32bd-412b-9db2-5fa2d3271415";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
29 changes: 29 additions & 0 deletions swiftScan/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour
["二维码/条形码生成", "myCode"],
["相册", "openLocalPhotoAlbum"]
]

var isSupportContinuous = false;

override func viewDidLoad() {
super.viewDidLoad()
Expand Down Expand Up @@ -55,6 +57,8 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour
openLocalPhotoAlbum()
return
}

isSupportContinuous = false;

switch indexPath.row {
case 0:
Expand Down Expand Up @@ -128,6 +132,12 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour
let vc = LBXScanViewController()

vc.scanStyle = style
vc.isSupportContinuous = true;

isSupportContinuous = true;

vc.scanResultDelegate = self

self.navigationController?.pushViewController(vc, animated: true)

}
Expand Down Expand Up @@ -167,6 +177,7 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour
style.xScanRetangleOffset = 30

let vc = LBXScanViewController()
vc.scanResultDelegate = self

vc.scanStyle = style
self.navigationController?.pushViewController(vc, animated: true)
Expand Down Expand Up @@ -242,6 +253,8 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour
vc.scanStyle = style

vc.isOpenInterestRect = true
vc.scanResultDelegate = self

//TODO:待设置框内识别
self.navigationController?.pushViewController(vc, animated: true)

Expand All @@ -265,6 +278,8 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour

let vc = LBXScanViewController()
vc.scanStyle = style
vc.scanResultDelegate = self

self.navigationController?.pushViewController(vc, animated: true)

}
Expand Down Expand Up @@ -296,6 +311,7 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour
let vc = LBXScanViewController()
vc.scanStyle = style
vc.readyString = "相机启动中..."
vc.scanResultDelegate = self

self.navigationController?.pushViewController(vc, animated: true)

Expand Down Expand Up @@ -323,6 +339,7 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour
style.animationImage = UIImage(named: "CodeScan.bundle/qrcode_scan_light_green")
let vc = LBXScanViewController()
vc.scanStyle = style
vc.scanResultDelegate = self

self.navigationController?.pushViewController(vc, animated: true)

Expand Down Expand Up @@ -399,6 +416,18 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour

func scanFinished(scanResult: LBXScanResult, error: String?) {
NSLog("scanResult:\(scanResult)")



if !isSupportContinuous {

DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(400)) {
let vc = ScanResultController()
vc.codeResult = scanResult
self.navigationController?.pushViewController(vc, animated: true)
}
}

}

}

0 comments on commit 3aa6961

Please sign in to comment.