iOS16突然發(fā)現(xiàn)原生掃條形碼時識別區(qū)域只有屏幕正中間小部分范圍有效,二維碼是正常的,開始以為是掃碼區(qū)域的問題,不斷修改rectOfInterest的值,就算改成全屏掃碼也只有中間區(qū)域能識別,后面Google網(wǎng)上借鑒相關(guān)文章,才知道原因所在:鏈接
iOS16中二維碼和條形碼不能同時添加,去掉AVMetadataObjectTypeQRCode條形碼就可以正常掃描了,但是二維碼又不能識別了,所以這個問題不知道后續(xù)的系統(tǒng)版本中蘋果會不會修復(fù),先記錄一下
這邊目前只能采用別的方案去掃碼:系統(tǒng)中另一個識別API:VNDetectRectanglesRequest
self.output.metadataObjectTypes=@[AVMetadataObjectTypeQRCode,
AVMetadataObjectTypeEAN13Code,
AVMetadataObjectTypeEAN8Code,
AVMetadataObjectTypeUPCECode,
AVMetadataObjectTypeCode39Code,
AVMetadataObjectTypeCode39Mod43Code,
AVMetadataObjectTypeCode93Code,
AVMetadataObjectTypeCode128Code,
AVMetadataObjectTypePDF417Code,
AVMetadataObjectTypeDataMatrixCode];