我需要知道在didFinishPickingMediaWithInfo之前选择的mediaType才能允许根据类型进行编辑。
如果您选择视频,那么它将是真的,如果您选择图像,它将是假的。
在sourceType = .camera的情况下,我这样做了:
cameraController.allowsEditing = cameraController.cameraCaptureMode == .video
答案 0 :(得分:0)
您可以选择mediaTypes
var imagePicker = UIImagePickerController()
适用于相机:
if UIImagePickerController .isSourceTypeAvailable(UIImagePickerControllerSourceType.camera) {
cameraController.sourceType = UIImagePickerControllerSourceType.camera
cameraController.allowsEditing = cameraController.cameraCaptureMode == .video
self.present(imagePicker, animated: true, completion: nil
}
对于来自图库的视频:您可以选择媒体类型:
cameraController.sourceType = UIImagePickerControllerSourceType.photoLibrary
cameraController.mediaTypes = [kUTTypeMovie as String]
cameraController.allowsEditing = true
self.present(imagePicker, animated: true, completion: nil)
仅适用于图片:
cameraController.sourceType = UIImagePickerControllerSourceType.photoLibrary
cameraController.allowsEditing = false
self.present(imagePicker, animated: true, completion: nil)