问题
I am using the following code:
func addAttachmentUtil() {
print("file attacher")
let file = UIImagePickerController()
file.delegate = self
file.sourceType = UIImagePickerControllerSourceType.photoLibrary
file.mediaTypes = ["public.image", "public.movie"]
file.videoMaximumDuration = 5.0
file.allowsEditing = false
self.present(file, animated: true)
{
}
}
However I also want to limit the file on the basis of size (which would be 25 MB). I am not able to understand how to do this? Help is much appreciated.
回答1:
You cannot limit what’s displayed or prevent the user from choosing a bigger video. After the user chooses, you can look at the file and decide to do nothing with it.
来源:https://stackoverflow.com/questions/52760358/how-do-i-limit-file-size-for-uiimagepickercontroller