我這樣做,需要對QR代碼驗證與層次結構類似這樣的iOS應用程序:如何停止AVCaptureSession正確
View
---Scan View
---Image View - cardBG
---Inside View
- 當視圖加載,掃描查看被隱藏。
- 當用戶點擊按鈕掃描時,內部視圖和圖像視圖被設置爲隱藏,顯示掃描視圖。
- 掃描完成後,內部和圖像再次出現。
的問題是,在步驟3:當我停止AVCaptureSession,即使在像in this question異步調度,它需要8-10秒刷新視圖。
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
if([_captureSession isRunning])[_captureSession stopRunning];
AVCaptureInput* input = [_captureSession.inputs objectAtIndex:0];
[_captureSession removeInput:input];
AVCaptureVideoDataOutput* output = (AVCaptureVideoDataOutput*)[_captureSession.outputs objectAtIndex:0];
[_captureSession removeOutput:output];
});
[self.bgImageView setHidden:NO];
[self.insideView setHidden:NO];
[self.scanView setHidden:YES];
[self.previewLayer removeFromSuperlayer];
我的問題是:如何獲得視圖以避免這種凍結?
可能是你通過這個線程 http://stackoverflow.com/questions/3741121/how-to-properly-release找到答案-an-avcapturesession 謝謝。 –