Comments (14)
Just one thing to know: when you call controller.reset(), it tells the scanner that it can capture new barcodes.
So, if you call controller.reset()
in the didCaptureCode
delegate (like in the example), you tell the scanner that it can scan again as soon as a barcode is scanned.
from barcodescanner.
@githotto Hey, did you change isOneTimeSearch
property to false
? Because setting it to true
should prevent delegate from being called multiple times.
from barcodescanner.
@vaymmarkov Hey, I tried indeed setting isOneTimeSearch to true, but with no noticeable improvement. However when I set the scannerController.codeDelegate, .errorDelegate and .dismissalDelegate to nil in my controller.reset() func, my problems seem to have gone. Should the isOneTimeSearch have the same effect or was it just me (after a long day of bug-fixing), because today your suggestions also seems to work!?
from barcodescanner.
@jeryRazakarison Thank you. That solved my problem!
from barcodescanner.
@MincDev how did you solve this?
I have controller.isOneTimeSearch = true
in my viewDidLoad(), but it still scans for multiple times after the barcodecontroller has been dismissed.
from barcodescanner.
@junweimah Remove the controller.reset()
from the didCaptureCode
delegate function. In the delegate function do what you need to do with the captured code and call controller.dismiss(animated: true, completion: nil)
to dismiss the controller.
from barcodescanner.
@MincDev
I did that, it goes back to the previous screen, however the cpu is on 100% all the time after that, and device becomes really hot. any idea?
from barcodescanner.
@junweimah I am not sure as mine immediately stops the scanning process and my CPU never reaches 100%. I had the same issue with the scanner scanning multiple times and removing the controller.reset()
solved it for me. What I am doing is scanning the code, then in the didCaptureCode
delegate function I am querying the code against a barcode API that returns details. I completely removed the controller.reset()
function from the delegate.
from barcodescanner.
@MincDev
This is my current didCaptureCode function
func barcodeScanner(_ controller: BarcodeScannerController, didCaptureCode code: String, type: String) {
print("Barcode Data: \(code)")
print("Symbology Type: \(type)")
controller.isOneTimeSearch = true
Timer.scheduledTimer(withTimeInterval: 1.0, repeats: false) { _ in
// controller.reset(animated: true)
controller.dismiss(animated: true, completion: nil)
}
}
After a successful scanning, the screen will go back my previous screen, because of controller.dismiss
, but my cpu goes up to 100%.
I click my scan button to bring user back to the scanning screen, but the 'Looking for your product' loading screen is still there, which is why I am guessing cpu is at 100% all the time.
How do I close the loading other than .reset?
from barcodescanner.
@junweimah remove the ‘controller.reset(animated: true) from the function. It is not needed here. If you call it the you are telling the scanner it is ready again to scan. Now you close it while you told it to get ready for scanning and that is why your cpu is at 100%. Just remove the reset and you will see everything wil work
from barcodescanner.
@MincDev
Actually i commented off that part. I try scanning for the first time, and then try to scan again to test whether it is running in the background, and I found that it won't scan for the second time, which is working.
But for some reason when I come back to the scanning screen, the loading screen(with the spinning square) is still there
from barcodescanner.
@junweimah I also do not have the ‘isOneTimeSearch = false’ in my delegate. I have nothing other than dismiss and just calling a function to for the API. Try taking the dismiss out of the scheduled timer. If that still doesnt work, then the problem is somewhere else. Maybe in the way you call the scanner to open?
from barcodescanner.
@MincDev
Possibly, ill have a further look, thanks
from barcodescanner.
As I commented before, setting isOneTimeSearch
property to true
prevents delegate from being called multiple times. Please also note that you should set this property before you present BarcodeScannerViewController
.
from barcodescanner.
Related Issues (20)
- resetWithError not working
- Scans outside of box.
- Barcode-Scan with Front camera is not working
- SPM installation - Invalid Resource '[email protected]' not found. HOT 2
- Arabic Language Localization HOT 3
- StateMessageProvider initializers
- Do not add subviews directly to the visual effect view itself, instead add them to the -contentView." HOT 1
- Scanner is unable to scan truncated PDF417 type barcodes HOT 1
- [!] Unable to find other source ref for `[email protected]` for target `BarcodeScanner`. HOT 3
- Error not sure issue HOT 2
- Remove - while setting collapsed constraints for MessageViewController
- iPad issue: Video capture viewport not working in split mode HOT 1
- Signing for "BarcodeScanner-Localization" requires a development team. HOT 12
- Hi, could I get help with rectOfInterest HOT 1
- Modernizing BarcodeScanner
- Issue with AVCaptureSession startRunning() method not calling in a background thread
- Cannot update to 5.0.1 HOT 2
- [!] Unable to find other source ref for `[email protected]` for target `BarcodeScanner`. HOT 2
- BarcodeScanner/BarcodeScanner.framework/BarcodeScanner' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. HOT 1
- Objective-C support? HOT 4
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 barcodescanner.