如何限制 UIImagePickerController 的文件大小? [英] How do I limit file size for UIImagePickerController?

查看:52
本文介绍了如何限制 UIImagePickerController 的文件大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码:

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)
    {
    }
}

不过,我也想根据文件大小(25 MB)来限制文件.我无法理解如何做到这一点?非常感谢帮助.

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.

推荐答案

您不能限制显示的内容或阻止用户选择更大的视频.用户选择后,您可以查看该文件并决定不对其进行任何操作.

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.

这篇关于如何限制 UIImagePickerController 的文件大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆