2017-11-08 3 views
0

iOS上でswiftを使用してバーコードscannnerを構築しています。これは最初にコードを書いたときには完全に機能しましたが、最近はプログラミングに戻り、いくつかのエラーを投げかけていることを知りました。 私は終了スキャンボタンユーザー押しボタンがあり、それはスキャンモードAVCaptureセッションで未解決の識別子 'stopRunning'エラーを修正する方法

を終了する必要があり、これはこれは

func exitScan() -> Void { 
    //Go back to ViewController 
    [self.captureSession, stopRunning]; 
    [self.videoPreviewLayer, removeFromSuperlayer]; 
    self.videoPreviewLayer = nil; 
    self.captureSession = nil; 
    self.navigationController?.popToRootViewController(animated: true) 

} 

Xcodeのは私のexitScan機能です

let exitScanButton: UIButton = { 
    let button = UIButton(type: .system) 
    button.backgroundColor = UIColor(r: 80, g: 101, b: 161) 
    button.setTitle("Exit", for: .normal) 
    button.setTitleColor(UIColor.white, for: .normal) 
    button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 16) 
    button.translatesAutoresizingMaskIntoConstraints = false 

    button.addTarget(nil, action: #selector(exitScan), for:.touchUpInside) 
    return button 
}() 

exitScanボタンです2つのエラーを投げる

未解決識別子「stopRunning」未解決識別子の

使用の「removeFromSuperlayer」私はこれをどのように問題を解決することができ、これは誤りであり、どのように

答えて

1

これはobjective-c構文です。スウィフトは

self.catpureSession.stopRunning()

self.videoPreviewLayer.removeFromSuperLayer()

なしセミコロンも。

関連する問題