xcode升级到9.0 swift改到swift4.0之后扫码一直不走回调 ,研究了好长时间,发现苹果把扫码的代理方法的参数变了之前的方法
func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [Any]!, from connection: AVCaptureConnection!)
func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, from connection: AVCaptureConnection!)
这是之前swift3.2的代理方法,swift4.0之后不会走这两个代理方法,原因是现在代理方法不一样了func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection)
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection)
swift4.0的两个代理方法对比之前的3.2方法,可以发现现在方法的参数变了
将之前的两个方法的参数改好,扫码就可以正常用了