国产成人a∨激情视频厨房,国产v亚洲v欧美v精品综合,heyzo高无码国产精品,国产av导航大全精品,成品人视频ww入口

Swfit3.0 實(shí)現(xiàn)掃描二維碼 , 不走代理方法或者是沒有掃描到數(shù)據(jù)??

//輸入設(shè)備 fileprivate lazy var input: AVCaptureDeviceInput? = { let device = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo) return try? AVCaptureDeviceInput(device: device) }() // 輸出對象 fileprivate lazy var output : AVCaptureMetadataOutput = { let output = AVCaptureMetadataOutput() output.metadataObjectTypes = output.availableMetadataObjectTypes output.setMetadataObjectsDelegate(self, queue: DispatchQueue.main) let centerViewFrame = self.centerView.frame let screenFrame = UIScreen.main.bounds // 測試發(fā)現(xiàn)系統(tǒng)是按照右上角作為參照, 并不是以左上角 let x = centerViewFrame.origin.y / screenFrame.size.height let y = centerViewFrame.origin.x / screenFrame.size.width let width = centerViewFrame.size.height / screenFrame.size.height let height = centerViewFrame.size.width / screenFrame.size.width output.rectOfInterest = CGRect(x: x, y: y, width: width, he<愛尬聊_百科知識>ight: height) return output }() // 會話 fileprivate lazy var session = AVCaptureSession() // 預(yù)覽圖層 fileprivate lazy var previewlayer: AVCaptureVideoPreviewLayer = { let layer = AVCaptureVideoPreviewLayer(session: self.session) layer?.frame = self.view.bounds return layer! }()

// MARK: - 二維碼掃描 extension QRCodeViewController: AVCaptureMetadataOutputObjectsDelegate { fileprivate func setupScanQRCode() { if !session.canAddInput(input) || !session.canAddOutput(output) { return } session.addInput(input) session.addOutput(output) view.layer.insertSublayer(previewlayer, at: 0) session.startRunning() } func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [Any]!, from connection: AVCaptureConnection!) { for objc in metadataObjects { let tempObjc = objc as! AVMetadataMachineReadableCodeObject CCLog(tempObjc.stringValue) } } }

不走后面的代理方法, 如果是因?yàn)闆]有掃描到數(shù)據(jù)而沒有走代理方法, 那這里寫的有什么問題嗎? 望指出


編輯 舉報 2023-04-29 14:11

0個評論

暫無評論...
驗(yàn)證碼 換一張
相關(guān)內(nèi)容