使用UIActivityViewController控制UIImage的文件名 [英] Control file name of UIImage send with UIActivityViewController
问题描述
我正在与 UIActivityViewController
共享一个图片,以及一个网址和一些文字。一切都很好,除了图像文件名始终是'Image-1'没有扩展名。在某些情况下,这会导致一个大问题,例如在邮件应用程序中根本不会打开没有扩展名的图像。
I'm sharing an image, along with a url and some text, with a UIActivityViewController
. Everything works great, except the image file name is always 'Image-1' with no extension. In some cases this causes a big problem, such as in the mail app which won't open an image without an extension at all.
图像是由图像生成的应用程序存在为 UIImage
。
The image is being generated by the application and exists as a UIImage
.
有没有办法控制文件名并添加正确的扩展名图像?
Is there a way to control the file name and add the correct extension to the image?
推荐答案
我知道控制UIImage的文件名或编码类型的唯一方法就是保存它到设备上的文件,然后将文件的URL提供给UIActivityViewController。有关可用于完成此操作的代码,请查看此答案。这种方法有一些明显的缺点,但对于大多数应用程序来说可能已经足够好了。
The only way I'm aware to control the filename or the encoding type of a UIImage is to save it to a file on the device, and then feed the URL of the file into the UIActivityViewController. Take a look at this answer for code you can use to accomplish this. This approach has some obvious drawbacks, but will probably be good enough for most applications.
这篇关于使用UIActivityViewController控制UIImage的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!