使用 PHPickerViewController,所选图像的结果将作为结果显示。我可以设置图像的顺序吗?
private func makePickerViewController(selectionLimit: Int) -> PHPickerViewController {
var config = PHPickerConfiguration()
config.selectionLimit = selectionLimit
config.filter = PHPickerFilter.images
let pickerViewController = PHPickerViewController(configuration: config)
return pickerViewController
}
func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
picker.dismiss(animated: true, completion: nil)
for (index, result) in results.enumerated() {
let itemProvider = result.itemProvider
if itemProvider.canLoadObject(ofClass: UIImage.self) {
itemProvider.loadFileRepresentation(forTypeIdentifier: "public.image") { (url, error) in
// How can you determine the order of the selected images?
}
}
}
}
例如,如果用户像上图那样选择它,那么它到结果的顺序应该是相同的。