我有AVCaptureSession的ViewController。我可以轻松地开始和停止AVCaptureSession:
var captureSession: AVCaptureSession?
captureSession = AVCaptureSession()
//start
captureSession?.startRunning()
//stop
captureSession?.stopRunning()
想知道当用户打开另一个ViewController时如何停止AVCaptureSession。
答案 0 :(得分:1)
让viewWillDisappear方法为您处理。
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
captureSession?.stopRunning()
}