PHPickerViewController 添加视频编辑屏幕又名 (UIImagePickerController.allowsEditing = true)

问题描述

我想在选择后编辑/压缩视频,就像在 UIImagePickerController 中使用 allowsEditing = true 一样。

新的 PHPickerViewController 仍然没有这个属性Apple 说没有这个属性here。但是 App Store 中有应用在从 PHPickerViewController

中选择资产后推送“allowsEditing controller”

这是我的 PHPickerViewController 实现:

func openImagePicker() {
        if #available(iOS 14,*) {
            var configuration = PHPickerConfiguration()
            configuration.preferredAssetRepresentationMode = .automatic
            let picker = PHPickerViewController(configuration: configuration)

            // Set the delegate
            picker.delegate = self
            // Present the picker

            present(picker,animated: true)
        } else {
            // Fallback on earlier versions
            imagePicker?.photogalleryAsscessRequest()
        }
    }

extension EditController: PHPickerViewControllerDelegate {
    @available(iOS 14,*)
    func picker(_ picker: PHPickerViewController,didFinishPicking results: [PHPickerResult]) {
        self.dismiss(animated: true)
   }
}

解决方法

我调查了这个问题,但确实没有像你提到的那样支持 allowsediting

例如,与您的问题相关的视频编辑预设值已折旧为 UIImagePickerController.ImageURLExportPreset.compatible,但不支持自动压缩。选择器将始终传递原始视频/图像,由应用程序进行必要的压缩或编辑。 您可以查看此 Apple 文档:imageExportPreset

Apple 特别提到我们应该使用这个新的而不是旧的 UIImagePickerViewController。如果有人想知道更多:Meet the new Photos picker

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...