拍摄照片和呈现新的视图控制器时,快门声音滞后

时间:2016-01-18 16:49:38

标签: ios swift

我正在制作一个相机应用程序,用户拍照,然后照片显示在新的视图控制器中。它工作正常,除了拍照时,iPhone快门音效在视图过渡期间真的被打破了。我不确定为什么会发生这种情况,但这是我按下捕获按钮时拍照的代码...有什么建议吗?

dispatch_async(captureSessionQueue) {

        let connection = self.stillCameraOutput.connectionWithMediaType(AVMediaTypeVideo)

        self.stillCameraOutput.captureStillImageAsynchronouslyFromConnection(connection) { sampleBuffer, error 
             if error == nil {

                     let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sampleBuffer)

                            if var image = UIImage(data: imageData) {
                                let imageCapturedVC = ImageCapturedViewController(sourceImage: image, capturedImageOrientation: self.currentOrientation, session: self.session, imageBundle: self.imageBundle)

                                dispatch_async(dispatch_get_main_queue()) {
                                    self.presentViewController(imageCapturedVC, animated: false, completion: nil)
                                }
                            }
                        }
                    }
                }
            }

0 个答案:

没有答案