EXC_BREAKPOINT(代码= EXC_ARM_BREAKPOINT,子代码= 0xe7ffdefe)

时间:2016-03-27 19:28:49

标签: ios swift

嗨,我收到了这个错误。

enter image description here

应该是因为这个代码(它应该在我的自定义相机中在前后相机之间切换)。我可以拍照,一切正常,除了这段代码......

 @IBAction func switchCamera(sender: UIButton) {

    var session:AVCaptureSession!

    let currentCameraInput: AVCaptureInput = session.inputs[0] as! AVCaptureInput
    session.removeInput(currentCameraInput)


     do {

    let newCamera: AVCaptureDevice?
    if(captureDevice!.position == AVCaptureDevicePosition.Back){
        print("Setting new camera with Front")
        newCamera = self.cameraWithPosition(AVCaptureDevicePosition.Front)
    } else {
        print("Setting new camera with Back")
        newCamera = self.cameraWithPosition(AVCaptureDevicePosition.Back)
    }

    let error = NSError?()
    let newVideoInput = try AVCaptureDeviceInput(device: newCamera)
     if (error == nil && captureSession?.canAddInput(newVideoInput) != nil) {
        session.addInput(newVideoInput)
    } else {
        print("Error creating capture device input")
    }

    session.commitConfiguration()

    captureDevice! = newCamera!

     } catch let error as NSError {
        // Handle any errors
        print(error)
    }


}

感谢。

0 个答案:

没有答案