yeahdongcn / RSBarcodes_Swift

1D and 2D barcodes reader and generators for iOS 8 with delightful controls. Now Swift.
MIT License
710 stars 185 forks source link

Not showing anything #53

Closed dtfiedler closed 8 years ago

dtfiedler commented 8 years ago

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?

yeahdongcn commented 8 years ago

Could you share me your code?

dtfiedler commented 8 years ago
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
        }
    }
drewantonich commented 8 years ago

Not sure if you are still working on this problem, @dtfiedler, but it looks like you need to call super.viewWillAppear() in viewWillAppear().

dtfiedler commented 8 years ago

Forgot about this post! That worked, thank you!