离开时停止 AVCaptureSession ViewController
Stop AVCaptureSession when leaving ViewController
我有 ViewController AVCaptureSession。我可以轻松启动和停止 AVCaptureSession :
var captureSession: AVCaptureSession?
captureSession = AVCaptureSession()
//start
captureSession?.startRunning()
//stop
captureSession?.stopRunning()
想知道当用户打开另一个 ViewController.
时如何停止 AVCaptureSession
让 viewWillDisappear 方法为您处理。
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
captureSession?.stopRunning()
}
我有 ViewController AVCaptureSession。我可以轻松启动和停止 AVCaptureSession :
var captureSession: AVCaptureSession?
captureSession = AVCaptureSession()
//start
captureSession?.startRunning()
//stop
captureSession?.stopRunning()
想知道当用户打开另一个 ViewController.
时如何停止 AVCaptureSession让 viewWillDisappear 方法为您处理。
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
captureSession?.stopRunning()
}