How do I limit file size for UIImagePickerController?

落爺英雄遲暮 提交于 2021-01-29 09:11:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!