我正在尝试在 UIImagePicker 中的视频捕获会话上覆盖视图。覆盖效果很好,但是当应用程序进入用户可以“重拍”、“播放”或“使用视频”的屏幕时,应用程序崩溃并给出错误:
2017-04-16 21:33:04.129212-0400 ChugMug [429:59833] libMobileGestalt MobileGestalt.c:2690: statfs(/mnt4): 没有这样的文件或目录 2017-04-16 21:33:04.129871-0400 ChugMug [ 429:59833] libMobileGestalt MobileGestalt.c:2587:SInt64 NANDSize():找不到磁盘 0 的 kIOMediaSizeKey!2017-04-16 21:33:09.352085-0400 ChugMug [429:60065] [MediaRemote] 错误操作需要已注册客户端回调。请求播放队列
代码很简单,当覆盖层被注释掉时,视频预览屏幕和按钮工作正常,但是当覆盖层存在时,应用程序冻结在以下屏幕:
这是相机和叠加层的代码:
func startMediaBrowserFromViewController(viewController: UIViewController, usingDelegate delegate: UINavigationControllerDelegate & UIImagePickerControllerDelegate) -> Bool {
// 1
if UIImagePickerController.isSourceTypeAvailable(.savedPhotosAlbum) == false {
return false
}
// 2
let mediaUI = UIImagePickerController()
mediaUI.sourceType = .savedPhotosAlbum
mediaUI.mediaTypes = [kUTTypeMovie as NSString as String]
mediaUI.allowsEditing = true
mediaUI.delegate = delegate
// 3
present(mediaUI, animated: true, completion: nil)
return true
}
func startCameraFromViewController(viewController: UIViewController, withDelegate delegate: UIImagePickerControllerDelegate & UINavigationControllerDelegate) -> Bool {
if UIImagePickerController.isSourceTypeAvailable(.camera) == false {
return false
}
cameraController.sourceType = .camera
cameraController.mediaTypes = [kUTTypeMovie as NSString as String]
cameraController.allowsEditing = false
cameraController.delegate = delegate
cameraController.showsCameraControls = true
//customView stuff
let customViewController = CustomOverlayViewController(
nibName:"CustomOverlayViewController",
bundle: nil
)
let customView = customViewController.view //as! CustomOverlayView
customView?.frame = cameraController.view.frame
present(cameraController, animated: true, completion: {
self.cameraController.cameraOverlayView = customView
customViewController.cameraLabel.text = "Camera Label"
self.cameraController.startVideoCapture()
})
return true
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
let mediaType = info[UIImagePickerControllerMediaType] as! NSString
dismiss(animated: true, completion: nil)
// Handle a movie capture
if mediaType == kUTTypeMovie {
guard let path = (info[UIImagePickerControllerMediaURL] as! NSURL).path else { return }
if UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(path) {
UISaveVideoAtPathToSavedPhotosAlbum(path, self, nil, nil)
}
}
}
我不知道是什么导致了这个奇怪的错误,也找不到类似的东西。我希望有一个人可以帮助我。