I'm doing an iOS application that need verification on QR Code with the Hierarchy like this:
View
---Scan View
---Image View - cardBG
---Inside View
- When view is loading, the Scan View is hidden.
- When user click button to scan, the Inside View and Image View is set hidden, reveal the Scan View.
- After the scanning return success, the Inside and Image appear again.
The problem is in step 3: when I stop AVCaptureSession, even in an asynchronous dispatch like in this question, the it takes 8-10 seconds to refresh the view.
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];
My question is: How can I get the view to avoid this freeze?