我有带AVCaptureSession的ViewController。我可以轻松启动和停止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()
}
关于ios - 离开ViewController时停止AVCaptureSession,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37394814/