Closed dtfiedler closed 8 years ago
Could you share me your code?
import UIKit
import RSBarcodes_Swift
class BarcodeVC: RSCodeReaderViewController {`
var barcodeString = ""
override func viewDidLoad() {
super.viewDidLoad()
self.focusMarkLayer.strokeColor = UIColor.redColor().CGColor
self.cornersLayer.strokeColor = UIColor.yellowColor().CGColor
self.navigationController?.navigationBarHidden = true
self.tapHandler = { point in
print(point)
if ((self.navigationController?.navigationBarHidden) == true ) {
self.navigationController?.navigationBarHidden = false
} else {
self.navigationController?.navigationBarHidden = true
}
}
self.barcodesHandler = { barcodes in
if self.barcodeString.isEmpty {
let barcode = barcodes.first
print("Barcode found: type=" + barcode!.type + " value=" + barcode!.stringValue)
self.barcodeString = barcode!.stringValue as! String
self.performSegueWithIdentifier("barcodeFound", sender: self)
}
}
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(animated: Bool) {
barcodeString = ""
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "barcodeFounde" {
let dVC = segue.destinationViewController as! BCResultViewController
dVC.barcodeString = barcodeString
}
}
Not sure if you are still working on this problem, @dtfiedler, but it looks like you need to call super.viewWillAppear()
in viewWillAppear()
.
Forgot about this post! That worked, thank you!
I have set up a ViewController as described, it worked a few times and I was able to scan codes, however now it just shows a black screen. I've given it access to my camera so I am not sure how to fix this issue. Any ideas?