ios - How to stop AVCaptureSession properly -


I am applying an iOS which requires verification on the QR code with hierarchy like this:

  see --- see the scan --- see the image - cardbieg --- inside view  
  1. When the view is loading, the scan view is hidden is.
  2. When the user clicks the button to scan, the scene and image view in it is hidden, reveal the scan view.
  3. After the success of the scanning return, the image inside and the image is visible again.

The problem is in step 3. When I stop AVCaptureSession is also like an asynchronous dispatch, it takes 8-10 seconds to refresh to see

< pre class = "lang- C prettyprint -override"> 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 = (AVCaptureVide Odataotput *) [_ capture Senshnautauts Objektaetindaks: 0]; [_capture session Extraction output: output];}); [Self. BgImageView sethead: NO]; [Self.ineviewview sethead: no]; [SelfScan Sethead: Yes]; [Self.previler removal user]];

My question is how do I get an idea of ​​avoiding this freeze?

Without much reference, would like to say hard to really depend on what is causing delays some of this work

  dispatch_async (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ {if ([_ captureSession isRunning]) [_ captureSession stopRunning] ;? Dispatch_async (dispatch_get_main_queue (), ^ {[ Self. bgImageView setHidden: NO]; [self.insideView setHidden: NO]; [self.scanView setHidden: YES]; [self.previewLayer removeFromSuperlayer];}); AVCaptureInput * input = [_captureSession.inputs objectAtIndex: 0]; [ _captureSession removeInput: input]; AVCaptureVideoDataOutput * output = (AVCaptureVideoDataOutput *) [_ captureSession.outputs objectAtIndex: 0] ; [_captureSession removeOutput: Production];});  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -