我正在使用 AVCaptureMetadataOutput
读取条形码。它调用委托(delegate)方法..
captureOutput(_ captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [Any]!, 来自连接: AVCaptureConnection!)
...当它匹配某物时。
除非用户将手指放在按钮上,否则如何让它忽略匹配项?
最佳答案
您可以向按钮添加多个操作。捕捉到当用户按下时,设置读取条码状态。捕捉到用户松手时,清除已读条码状态。
func viewDidLoad() {
...
button.addTarget(self, action:#selector(buttonDown), for:.touchDown)
button.addTarget(self, action:#selector(buttonUp), for:.touchUpInside)
button.addTarget(self, action:#selector(buttonUp), for:.touchUpOutside)
...
}
func buttonDown() {
startReadBarcode()
}
func buttonUp() {
stopReadBarcode()
}
关于ios - 仅在按住按钮时扫描条形码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44162498/