2016-05-23 5 views
1

私はAVCaptureSessionでViewControllerを持っています。私は簡単にAVCaptureSessionを開始および停止することができますViewControllerから離れるときにAVCaptureSessionを停止する

var captureSession: AVCaptureSession? 
captureSession = AVCaptureSession() 

//start 
captureSession?.startRunning() 

//stop 
captureSession?.stopRunning() 

Aは、ユーザーが別のViewControllerを開いたとき、私はAVCaptureSessionを停止することができます方法を知りたいです。

+0

例えば 'viewWillDisappear'では、 – Larme

答えて

1

ちょうどviewWillDisappearメソッドがそれを処理します。

override func viewWillDisappear(animated: Bool) { 
    super.viewWillDisappear(animated) 
    captureSession?.stopRunning() 
} 
関連する問題