我正在尝试让录音摄像机出现 - 它因信号 SIGABRT 而崩溃

Eri*_*sta 1 crash ios swift

当应用程序崩溃时,它会在控制台中显示 (lldb)。不太确定为什么会崩溃。

但我很确定它与显示相机的功能有关:

let imagePicker: UIImagePickerController! = UIImagePickerController()

func shootADance() {

     if (UIImagePickerController.isSourceTypeAvailable(.camera)) {
        if UIImagePickerController.availableCaptureModes(for: .rear) != nil {

            //if the camera and rear camera is available, dod this

            imagePicker.sourceType = .camera
            imagePicker.mediaTypes = [kUTTypeMovie as String]
            imagePicker.allowsEditing = false
            imagePicker.delegate = self as? UIImagePickerControllerDelegate & UINavigationControllerDelegate

            present(imagePicker, animated: true, completion: nil)
        } else {
            postAlert("Rear camera doesn't exist", message: "Application cannot access the camera.")
        }
    } else {
        postAlert("Camera inaccessable", message: "Application cannot access the camera.")
    }      
}
Run Code Online (Sandbox Code Playgroud)

这是控制台中出现的内容

2017-07-25 04:16:02.602 appName[11003:] Firebase Analytics v.3600000 已启动

2017-07-25 04:16:02.602 appName[11003:] 要启用调试日志记录,请设置以下应用程序参数:-FIRAnalyticsDebugEnabled(请参阅blockedLink)

2017-07-25 04:16:02.615:启用 FIRInstanceID AppDelegate 代理,将调整应用程序委托远程通知处理程序。要禁用,请将“FirebaseAppDelegateProxyEnabled”添加到 Info.plist 并将其设置为 NO

2017-07-25 04:16:02.653 appName[11003:] 成功自动创建 Firebase Analytics 应用程序委托代理。要禁用代理,请在 Info.plist 中将标志 FirebaseAppDelegateProxyEnabled 设置为 NO

2017-07-25 04:16:02.670 appName[11003:] AdSupport 框架当前未链接。某些功能将无法正常运行。了解更多信息,请访问 2017-07-25 04:16:02.691 Koala[11003:] Firebase Analytics 已启用 { (lldb)

看起来没有错误消息,但我知道这是 ShootADance 函数(源类型)

这是 Xcode 崩溃时显示的内容并显示信号 SIGABR

先感谢您!

Ale*_*nko 5

在 iOS 10 之后,您必须在 Info.plist 中定义并提供摄像头和麦克风的使用说明:

Privacy - Microphone Usage Description : $(PRODUCT_NAME) microphone use
Privacy - Camera Usage Description : $(PRODUCT_NAME) camera use
Run Code Online (Sandbox Code Playgroud)