ios - 选择视频时 iOS 10.3 中的 UIImagePickerController 崩溃

标签 ios swift crash uiimagepickercontroller

所以我正在做我已经写了数百次的非常简单的图像选择器。为此,我写了这个非常简单的扩展:

extension UIImagePickerController {

    func present(over controller: UIViewController,
                 with source: UIImagePickerControllerSourceType,
                 mediaTypes: [String]? = nil) {

        DispatchQueue.main.async {
            self.allowsEditing = true
            self.sourceType = source
            if source == .camera {
                self.cameraDevice = .front
            }
            self.modalPresentationStyle = .popover
            self.mediaTypes = mediaTypes ?? UIImagePickerController.availableMediaTypes(for: source) ?? []
            controller.present(self, animated: true, completion: nil)
        }
    }
}

而且效果很好。那当然是在您选择视频之前。 一旦你选择了一个视频,我就会得到堆栈跟踪的美丽:

BEAUTIFUL!!!!!

在你问之前。是的,我已经在我的 Info.plist 中设置了所有隐私设置:

NSPhotoLibrary使用说明 NS麦克风使用说明 NSCameraUsageDescription

这可能是 10.3 中的 Beta 版问题吗?我希望如此 ;)

编辑:我设法在另一台设备上对此进行了测试,它与测试版没有任何关系。

到目前为止,我最好的竞争者是:

  • 我搞砸了(很有可能)
  • 其他东西(可能是依赖项)正在注册错误的通知

最佳答案

几小时后我发现了问题。原来项目中有人认为写这个是个好主意:

        NotificationCenter.default.addObserver(forName: nil,
            object: nil,
            queue: nil) { note in

                // Some strange code we were not using anymore
                // Mainly logging all activity made as Notifications
        }

他只是想要更多日志。 这似乎与:

  • AVPlayer 中的一些 C++ 异常
  • 使用 URL 获取本地 AVAssets

非常感谢;)

是时候使用 Git Blame 了!

关于ios - 选择视频时 iOS 10.3 中的 UIImagePickerController 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42610096/

相关文章:

iOS PDF 原生搜索

swift - 更新用http加载的注释

swift - 动态 View 取决于自由形式移动的 View 数量

Swift 获取 Idfa 崩溃

ios - 如何在其父 View 中完全限制 subview (这是一个 UIImageView)?

iphone - 在gdata集成中从uiweb View 重定向返回

delphi - XE6 中的 TOpenFileDialog 访问冲突

c++ - 尝试处理类的 vector 成员时程序崩溃

css - iOS 防止位置固定元素缩放

iphone - CLLocation 和 double 的问题