hyperoslo / barcodescanner Goto Github PK
View Code? Open in Web Editor NEW:mag_right: A simple and beautiful barcode scanner.
Home Page: http://hyper.no
License: Other
:mag_right: A simple and beautiful barcode scanner.
Home Page: http://hyper.no
License: Other
REPRO STEPS:
BarcodeScannerController
ACTUAL:
flashlight symbol is greyed out!
EXPECTED:
not greyed out
Code we use to call it:
let barcodeController = BarcodeScannerController()
barcodeController.codeDelegate = self
barcodeController.errorDelegate = self
barcodeController.dismissalDelegate = self
appDelegate = UIApplication.shared.delegate as! AppDelegate
if UIDevice.current.orientation == UIDeviceOrientation.landscapeLeft {
appDelegate.barCodeScannerOrientation = .landscapeRight
} else {
appDelegate.barCodeScannerOrientation = .landscapeLeft
}
barcodeController.reset()
if let strongself = self {
if AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) == AVAuthorizationStatus.authorized {
// Already Authorized
strongself.present(barcodeController, animated: true, completion: nil)
} else if AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) == AVAuthorizationStatus.notDetermined {
AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo, completionHandler: { (granted: Bool) -> Void in
if granted == true {
// User granted
DispatchQueue.main.async {
strongself.present(barcodeController, animated: true, completion: nil)
}
}
})
} else if AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) == AVAuthorizationStatus.denied {
let alertController = UIAlertController(title: "Camera Access",
message: "The camera permission was not authorized. Please enable it in Settings to continue.",
preferredStyle: .alert)
let settingsAction = UIAlertAction(title: "Settings", style: .default) { (alertAction) in
if let appSettings = NSURL(string: UIApplicationOpenSettingsURLString) {
UIApplication.shared.openURL(appSettings as URL)
}
}
alertController.addAction(settingsAction)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
alertController.addAction(cancelAction)
strongself.present(alertController, animated: true, completion: nil)
}
}
On smaller iPhones, the big texts does not fit on the numberOfLines
set.
For now, we can set the numberOfLines
parameter to 3.
It would be nice later to do a adjustment using autolayout to support any text size.
When rotating an iPad with the BarcodeScanner open, the frame isn't changed correctly. This leaves black space around the camera view, as well as leaving the image unrotated.
Essentially, every time the frame changes, the Barcode Scanner does not change frame, causing it to look wrong.
Guys,
I was wondering why you are not create release tags on the repository. In theory, the last version released was 2.0 on Oct 13 2016 and the repository is quite active.
Is there any reason for this?
When calling dismiss on the BarcodeScannerController
outside of barcodeScannerDidDismiss
delegate method, the iOS device CPU goes to over 100%
After scanning a barcode the "Looking for your product..." animation will not dismiss. Based on the below code the assumed behavior would be that the scanner would reset so that I can scan another code. Am I missing something?
func barcodeScanner(_ controller: BarcodeScannerController, didCaptureCode code: String, type: String) {
print("Capture Successful")
print("code: \(code): type: \(type)")
capturedCodes.insert(code)
controller.reset(animated: true)
}
Also, using controller.resetWithError(message: String?)
does not seem to work correctly either. The error appears briefly but then changes to the "Looking for your product..." animation and remains as describe above.
Hi,
my app uses a dark theme with an custom color UINavigationBar. Is there a way to change the color of the navigation bar which is visible while scanning?
When using the following code fragment:
func barcodeScanner(_ controller: BarcodeScannerController, didCaptureCode code: String, type: String) { print("\(type(of: self)).barcodeScanner(,code=\(code),type=\(type)") let delayInSeconds = 0.5 var segueId = "" DispatchQueue.main.asyncAfter(deadline: .now() + delayInSeconds) { //My scanned code handling goes here ... } }
I am getting the following output:
HomeScreenViewController.barcodeScanner(,code=Endoscope,type=org.iso.QRCode HomeScreenViewController.barcodeScanner(,code=Endoscope,type=org.iso.QRCode HomeScreenViewController.barcodeScanner(,code=Endoscope,type=org.iso.QRCode HomeScreenViewController.barcodeScanner(,code=Endoscope,type=org.iso.QRCode HomeScreenViewController.barcodeScanner(,code=Endoscope,type=org.iso.QRCode HomeScreenViewController.barcodeScanner(,code=Endoscope,type=org.iso.QRCode
where I only expect one call! I configure the scanner according to the delegate's example.
How can I prevent this from happening, since I want to call a performSegue(..) call, depending on
the scanned-code. What I see now is that 6 times a specific performSegue() will be called, giving me 6 times the same ViewController on my NavigationController-stack?
Anybody now a means how to prevent the barcodeScanner-delegate callback from being called more than one time?
I tried to scan barcode type Code128 with 23 symbol.
But I can't detect it. Any idea?
Anyone have Issue with delay appearing navigation bar with buttons?
I have it
Also its stupid when self.navigationController?.pushViewController(controller, animated: false)
I have the below set up to dismiss the controller once bar code has been scanned but the controller stays at "Looking for your product..." animation:
extension ViewController: BarcodeScannerCodeDelegate {
func barcodeScanner(_ controller: BarcodeScannerController, didCaptureCode code: String, type: String) {
controller.dismiss(animated: true)
}
}
I am running Xcode 9.1 on device with iOS 11.1.
It would be nice if the interface (target area, icons) were adapted to QR codes too.
Just a suggestion.
Hi!
is there any chance to move close button from left to right top corner?
Currently, only 2 lines are allotted for displaying messages, which may not work when displaying longer messages. It would also be nice to be able to adjust the line spacing as well to make longer messages a little easier to read.
It appears the default duration is .5 for a .processing state or when changing from .processing or .notFound state. It would be nice to be able to control that for cases where users may read slower or the message is longer.
I see delegate return only code. So How can I get type?
Is it possible to specify a single barcode type to be used?
I want to allow the app only to read one barcode type.
Tks
Hi
I tried to install this lib via Cocoapods using the command
pod 'BarcodeScanner'
as explained in the help, but I get the following message error in the Terminal running pod install:
Unable to find a specification for
BarcodeScanner
Thanks for your help
In portrait on iPhoneX, the header view with the close button and title label are too close to the notch. There's very little of the close button that is a tappable target as a result. Looks like it needs to be refactored to use safe areas.
Can you update cocoaPod to get updated version for Swift 4
The scanner continues to attempt to scan after the controller is dismissed.
I've updated the BarcodeScanner Framework and the Example project to Swift 4 with Base SDK 11 and changed the deployment target to iOS 10.3 (since anything less than 10.3 has less than a 9% market share).
I've also added support for all orientations and fixed a bug where the Header would disappear if the rotation was changed.
I also added all the new barcode types to the metadata array.
I also added support for iPhone and iPad device.
I also took the liberty of making some code better.
I've tested all the barcode types and general stability of the framework and example project.
Would you like me to submit a Pull Request to add all these features to your Scanner?
Does BarcodeScanner give support for EAN-13 barcodes ?
I need to change the color of the header. I don't think it's publicly available in Config.
For what I understood, it is the HeaderView
I need BarcodeScanner to add support for Interleaved 2 of 5 because they are commonly used for airplane luggage tags.
Just thought I'd make you aware, that for some reason the square that is used for the loading animation does not display it's corner radius correctly. It is no big deal, and is purely cosmetic but I thought I'd highlight it. I have tried increasing the corner radius myself, but it does not seem to have any effect.
Is there any method to change the scan position from center area to top or bottom?
I have just updated all the pods of my project by hitting pod update
command.
all the libraries are updated to latest version.
The problem is this library has version 2.0.0 (older) which is updated to 3.0.0 (newer).
And getting compile time errors.
I am using latest Xcode Version 9.0 (9A235).
What should I do?
Does this library support Objective-C project? I tried to install via CocoaPod with use_framework
but it seems not working
Pod crashes app on ios 11
I think line 67 in InfoView.swift is at fault here !?
Example code:
self.barcodeScanner = BarcodeScannerController()
self.barcodeScanner?.codeDelegate = self
self.barcodeScanner?.errorDelegate = self
//self.barcodeScanner?.view.subviews[0].isHidden = true
return barcodeScanner
Console error:
*** Assertion failure in -[BarcodeScanner.InfoView _addSubview:positioned:relativeTo:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3683.300.2/UIVisualEffectView.m:1364
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '<UILabel: 0x127d23f60; frame = (0 0; 0 0); userInteractionEnabled = NO; layer = <_UILabelLayer: 0x1c40992d0>> has been added as a subview to <BarcodeScanner.InfoView: 0x127d51a10; baseClass = UIVisualEffectView; frame = (0 0; 0 0); layer = <CALayer: 0x1c4227d40>>. Do not add subviews directly to the visual effect view itself, instead add them to the -contentView.'
*** First throw call stack:
(0x184f9d858 0x183774528 0x184f9d72c 0x185ad2280 0x18be0d26c 0x10344d2c8 0x10343fb4c 0x10344d3f8 0x10398bf7c 0x1037bc73c 0x10344d0b4 0x10344d424 0x10344cd14 0x10343b1d0 0x10343f204 0x10343fe44 0x18b7ab6bc 0x18b7ab294 0x18b92fafc 0x18b8529d0 0x18b8525f0 0x18b8524f8 0x18b7a8a64 0x1887816e4 0x18878579c 0x1886f83f8 0x18871de44 0x18871ec68 0x184f43a6c 0x184f41514 0x184f419f8 0x184e60280 0x186971f94 0x18b80f0f0 0x102cd8cc0 0x183c51e40)
libc++abi.dylib: terminating with uncaught exception of type NSException
Any plans to support MSI-PLESSEY?
It is still widely in use.
:)
I'm trying to read barcodes with the library but when I try to open the scanner with ios 11 I get this error and the app breaks:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '<UILabel: 0x1014a97d0; frame = (0 0; 0 0); userInteractionEnabled = NO; layer = <_UILabelLayer: 0x1c02936a0>> has been added as a subview to <BarcodeScanner.InfoView: 0x1015780d0; baseClass = UIVisualEffectView; frame = (0 0; 0 0); layer = <CALayer: 0x1c4226100>>. Do not add subviews directly to the visual effect view itself, instead add them to the -contentView.'
I'm using iOS 11 Beta 4
The library version is 2.1.1
Hello, is there a way to customize the info view? Change the background color, hide it and other stuff like this.
Not a huge issue, but just want to make sure this doesn't happen on production devices with no camera (are there any? ipod?)
seems this line:
lazy var captureDevice: AVCaptureDevice = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo)
is causing the EXC_BAD_ACCESS
error crash when pressing the "Scan" button:
fatal error: unexpectedly found nil while unwrapping an Optional value
2017-10-02 10:35:40.653827-1000 BarcodeScannerExample[34615:904682] fatal error: unexpectedly found nil while unwrapping an Optional value
Getting this error :::::
dyld: Library not loaded: @rpath/BarcodeScanner.framework/BarcodeScanner
Referenced from: /var/containers/Bundle/Application/154B00B7-2208-42B6-840F-6F02FCCA5AE2/(AppName).app/(AppName)
Reason: image not found
I'm using Xcode 8.2.1 and the barcodescanner pod version latest.....
pod installation was successful.. pod version is 1.2.0....... can you address this issue ASAP
Great library, congrats!
How can I retrieve a UIImage, for instance a string like r2Us1gf907 on a box.
If we can manipulate the auto focusing window to detect strings, that's awesome, but I do not know how.
If we can not do that, how can we add something like this?
And lastly, how can I retrieve the UIImage after the focus and taking the shot?
We may have to add a camera button for it probably, since the library auto captures the barcodes by itself.
OR
We can make it auto capture enabled for alphanumeric strings, but I do not know how yet.
Hope to see wisdom below.
Thanks!
I have been successfully using the scanner by pushing it on to the navigation stack. Now however I would like to present it. Strangely the built-in navigation bar is hidden. It seems like the isBeingPresented
check is not returning the correct result. The navigation bar does show but once the modal animation has completed and the bar has reached the top of the screen it disappears. I have pasted my code below.
// Configure barcode scanner
let controller = BarcodeScannerController()
controller.codeDelegate = self
controller.dismissalDelegate = self
controller.errorDelegate = self
controller.hidesBottomBarWhenPushed = true
// Set strings
BarcodeScanner.Info.loadingText = NSLocalizedString("Retrieving code...", comment: "")
// Display scanner
navigationController?.present(controller, animated: true, completion: nil)
Is there a way I can manually set the navigation bar visibility?
Hi,
I would like to put the BarcodeScannerController inside a ContainerView (in order to have the Barcode scanner on the top half of the screen, and a tableview with the list of scanned barcode on the bottom half of the screen).
But when I tries to embed the BarcodeScannerController in a container which sizes the half of the height of the screen, the preview is flattened. Do anyone have an idea of how to fix it?
Thank you a lot,
Jery
Hi,
i am trying to install barcode scanner through pods and installs swift 2.3 version and not supported in swift 3. please advice how to install the latest version of bar code scanner which supports swift 3
CocoaPods
and Carthage
are awesome tools and make our life really easier, but there are some devs who still don't know how to use them.
It would be cool to add the Manual installation guide in your README.md
. You can take a look at my iOS Readme Template to see how you can do it.
When I trying to install, it show [!] Unable to find a specification for BarcodeScanner
My project already up to swift 3.0. except this library. Do you guys update it?
Hi, since i update to xcode 9, i have this crash when open scanner :
'<UILabel: 0x15fe958c0; frame = (0 0; 0 0); userInteractionEnabled = NO; animations = { contentsMultiplyColor=<CABasicAnimation: 0x1c023b100>; }; layer = <_UILabelLayer: 0x1c409d920>> has been added as a subview to <BarcodeScanner.InfoView: 0x15fe948a0; baseClass = UIVisualEffectView; frame = (0 0; 0 0); layer = <CALayer: 0x1c4236300>>. Do not add subviews directly to the visual effect view itself, instead add them to the -contentView.'
I fix this issue by changing
[label, imageView, borderView].forEach {
self.contentView.addSubview($0)
}
Should i submit PR for this ?
"SCAN_BARCODE_TITLE" = "扫描条形码";
"BUTTON_CLOSE" = "关闭";
"BUTTON_SETTINGS" = "设置";
"INFO_DESCRIPTION_TEXT" = "将条形码放置在窗口内进行扫描,将自动搜索。";
"INFO_LOADING_TITLE" = "寻找你的产品…";
"NO_PRODUCT_ERROR_TITLE" = "没有发现产品。";
"ASK_FOR_PERMISSION_TEXT" = "你必须在设置里面打开相机权限才可以扫描条码。";
Close any time.
Is it possible to place support for:
AVMetadataObjectTypeInterleaved2of5Code
Tks!
I integrated the BarcodeScanner POD in the project and it runs perfectly on iOS 10. However on iOS 11 its giving me the below error. Please update your pod to work with Swift 4.
2017-10-15 17:11:16.427039+0530[1797:1731968] [MC] Lazy loading NSBundle MobileCoreServices.framework
2017-10-15 17:11:16.428545+0530[1797:1731968] [MC] Loaded MobileCoreServices.framework
2017-10-15 17:11:17.538814+0530[1797:1731968] *** Assertion failure in -[BarcodeScanner.InfoView _addSubview:positioned:relativeTo:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3694.4.18/UIVisualEffectView.m:1464
2017-10-15 17:11:17.543583+0530[1797:1731968] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '<UILabel: 0x127dc0580; frame = (0 0; 0 0); userInteractionEnabled = NO; layer = <_UILabelLayer: 0x1c0481540>> has been added as a subview to <BarcodeScanner.InfoView: 0x127d250a0; baseClass = UIVisualEffectView; frame = (0 0; 0 0); layer = <CALayer: 0x1c043c8e0>>. Do not add subviews directly to the visual effect view itself, instead add them to the -contentView.'
*** First throw call stack:
(0x182c9fd38 0x1821b4528 0x182c9fc0c 0x18362ec24 0x18c73c7a8 0x10595cda4 0x10594dadc 0x10595ced4 0x106263a50 0x106076b94 0x10595cb20 0x10595cf00 0x10595c650 0x1059487f4 0x10594d194 0x10594dd7c 0x18c0afbfc 0x18c0af7d4 0x18cc3c8b0 0x18c3f23b0 0x18c422034 0x18c424f54 0x18c425488 0x18c424ea4 0x18c18f55c 0x104b40ea8 0x104b41074 0x18c0e420c 0x18c0e418c 0x18c0cef4c 0x18c0e3a80 0x18c0e35a0 0x18c0dea70 0x18c0b0078 0x18c9eff98 0x18c9f2408 0x18c9eb574 0x182c48358 0x182c482d8 0x182c47b60 0x182c45738 0x182b662d8 0x1849f7f84 0x18c113880 0x104994b8c 0x18268a56c)
libc++abi.dylib: terminating with uncaught exception of type NSException
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.