二維碼掃描在設(shè)置條碼類型時出現(xiàn)崩潰
崩潰位置如下圖所示:

崩潰位置.png
提示錯誤如下:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureMetadataOutput setMetadataObjectTypes:] Unsupported type found - use -availableMetadataObjectTypes'
*** First throw call stack:
(0x1826241c0 0x18105c55c 0x189db1898 0x10014e298 0x1884663dc 0x188465fa4 0x188e29d34 0x1887b0d28 0x1887d2194 0x1887d5060 0x188558e80 0x1003a4c34 0x18849b7b0 0x18849b730 0x188485be4 0x18849b01c 0x188a2bf30 0x188a27fc8 0x188a27ae8 0x188a26da4 0x188495d70 0x188466858 0x188c53cb8 0x188c4d720 0x1825d2278 0x1825d1bc0 0x1825cf7c0 0x1824fe048 0x183f81198 0x1884d1628 0x1884cc360 0x1003d0474 0x1814e05b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
崩潰原因:
由于關(guān)于項目的中的相機(jī)授權(quán)在設(shè)備系統(tǒng)中沒有打開,并且項目中沒有對相機(jī)授權(quán)開啟作出判斷導(dǎo)致的崩潰。
解決辦法:
在代碼中設(shè)置條碼類型以前進(jìn)行系統(tǒng)相機(jī)授權(quán)判斷即可
NSString *mediaType = AVMediaTypeVideo;
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];
if(authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied){
UIAlertView *alert =[[UIAlertView alloc]initWithTitle:nil message:@"請在iPhone的“設(shè)置”-“隱私”-“相機(jī)”功能中,找到“(自己項目名稱)”打開相機(jī)訪問權(quán)限" delegate:nil cancelButtonTitle:@"確定" otherButtonTitles: nil];
alert.delegate = self;
[alert show];
return;
}