相关疑难解决方法(0)

使用AVFoundation在Swift 3.0中扫描条形码或QR码

我正在按照本教程尝试将代码从Swift 2.0转换为3.0.但是当我启动应用程序时,该应用程序无法运行!我的意思是,没有任何反应 这是我的代码:

视图控制器:

class ViewController: UIViewController ,BarcodeDelegate {

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

        let barcodeViewController: BarcodeViewController = segue.destination as! BarcodeViewController
        barcodeViewController.delegate = self

    }



    func barcodeReaded(barcode: String) {
        codeTextView.text = barcode
        print(barcode)
    }

}
Run Code Online (Sandbox Code Playgroud)

BarcodeVC:

import AVFoundation


protocol BarcodeDelegate {

    func barcodeReaded(barcode: String)
}

class BarcodeViewController: UIViewController,AVCaptureMetadataOutputObjectsDelegate {

    var delegate: BarcodeDelegate?
    var captureSession: AVCaptureSession!
    var code: String?


    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        print("works")

        self.captureSession = …
Run Code Online (Sandbox Code Playgroud)

ios avcapturesession swift swift3

14
推荐指数
2
解决办法
2万
查看次数

标签 统计

avcapturesession ×1

ios ×1

swift ×1

swift3 ×1