Comments (11)
func performQR(){
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.performSegueWithIdentifier("toQR", sender: self)
})
}
You need to switch to main thread to perform UI related operations.
from rsbarcodes_swift.
The barcodesHandler was designed non thread safe, because we may perform some actions which may take long time.
from rsbarcodes_swift.
Could you try the code I provided?
from rsbarcodes_swift.
Thank you very much for the reply. I am unable to test the code tonight, but I will tomorrow.
from rsbarcodes_swift.
I tested the code and it does perform the segue. My only issue now is that the segue is performed multiple times and doesn't just stop after a valid scan happened. Is there a way to stop the scanning process immediately after a valid scan took place?
self.barcodesHandler = { barcodes in
for barcode in barcodes {
println("Barcode found: type=" + barcode.type + " value=" + barcode.stringValue)
if let builtObject = self.ObjectHelper.validateAndBuild(barcode,
scannedData: barcode.stringValue){ // If built object is valid
self.performQR() // End scanning here and perform segue once
}
}
}
from rsbarcodes_swift.
You can add a break
after you call self.performQR()
from rsbarcodes_swift.
Unfortunately, adding the break still causes multiple segues to occur. A solution I found is to add self.session.stopRunning()
before self.performQR()
and then add a break
. Is it safe to stop the session like this?
self.barcodesHandler = { barcodes in
for barcode in barcodes {
println("Barcode found: type=" + barcode.type + " value=" + barcode.stringValue)
if let builtObject = self.ObjectHelper.validateAndBuild(barcode,
scannedData: barcode.stringValue){ // If built object is valid
self.finalObject = builtObject // Assign finalObject for segue purposes
self.session.stopRunning()
break
}
else {
self.displayInvalidScan()
}
}
self.handleSegue()
}
from rsbarcodes_swift.
Yeah, you're right, I forgot this line.
from rsbarcodes_swift.
I posted this conversation to SO to be more reachable.
from rsbarcodes_swift.
Great, thank you!
from rsbarcodes_swift.
👍
from rsbarcodes_swift.
Related Issues (20)
- Add Swift Package Manager support HOT 1
- Can not scan any barcode when any filter is applied to Camera app.
- Can not generate with Unicode character ¿
- how to check UPC - A Code validate ? HOT 3
- How to change color of resized barcode?
- XCode 12 Beta 6, compiler error HOT 5
- Last release was in 2018 HOT 1
- Change to the front camera does not work
- Why scan 1D Barcode only in middle of view?
- Support for BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
- 'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead on iOS 15 Betas. HOT 5
- Cannot generate interleaved2of5 HOT 1
- Is it possible to use this library omitting features accessing iPhone camera because I do not use camera feature in my app and would like to remove NSCameraUsageDescription in info.plist. HOT 3
- Invalid CFBundleIdentifier
- Xcode 14.2 - self.session.startRunning()
- EAN13 generation not working
- RSCodaBarGenerator doesn't appear to be in 5.2.0 Swift Package Release
- 'shared' is unavailable in application extensions for iOS
- [Privacy Manifest] Implementation HOT 2
- Can't generate Codabar Barcode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rsbarcodes_swift.