我这样做,需要对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 谢谢。 –