我试图选择资产来PHPickerViewController
替代 my UIImagePickerController
,但是在设置filter
和config
选项时,我没有看到设置返回视频长度限制的方法。即使用UIImagePickerController
through的方式videoMaximumDuration
。
有没有人找到任何锻炼方式?
private func presentPicker(filter: PHPickerFilter?)-> PHPickerViewController {
var configuration = PHPickerConfiguration(photoLibrary: .shared())
// Set the filter type according to the user’s selection.
configuration.filter = filter
// Set the mode to avoid transcoding, if possible, if your app supports arbitrary image/video encodings.
configuration.preferredAssetRepresentationMode = .current
// Set the selection behavior to respect the user’s selection order.
configuration.selection = .ordered
// Set the selection limit to enable singular selection.
configuration.selectionLimit = 1
// Set the preselected asset identifiers with the identifiers that the app tracks.
configuration.preselectedAssetIdentifiers = []
let picker = PHPickerViewController(configuration: configuration)
//picker.delegate = self
//present(picker, animated: true)
return picker
}