iOS13共享表:共享UIImage时如何设置预览缩略图 [英] iOS13 share sheet: how to set preview thumbnail when sharing UIImage

查看:239
本文介绍了iOS13共享表:共享UIImage时如何设置预览缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS13上的新共享表在其左上角显示了正在共享的项目的预览/缩略图.

The new share sheet on iOS13 shows a preview/thumbnail of the item being shared on its top left corner.

使用UIActivityViewController共享UIImage时,我希望在此处显示正在共享的图像的预览/缩略图(例如,例如,共享附加到内置Mail应用程序的图像时),但是共享页却显示了我的应用程序的图标.

When sharing an UIImage using an UIActivityViewController I would expect a preview/thumbnail of the image being shared to be displayed there (like e.g. when sharing an image attached to the built in Mail app), but instead the share sheet is showing my app's icon.

在共享表中显示要导出的图像的缩略图需要哪些代码/设置?

What code/settings are required to show a thumbnail of the image being exported in the share sheet?

我已经如下设置了UIActivityViewController:

I have set up the UIActivityViewController as follows:

let image = UIImage(named: "test")!
let activityVC = UIActivityViewController(activityItems: [image], applicationActivities: nil)                          
activityVC.popoverPresentationController?.sourceView = self.view                            
self.present(activityVC, animated: true, completion: nil)

推荐答案

只需将图像URL传递给UIActivityViewController而不是UIImage对象. 例如:

Just pass the image urls to UIActivityViewController not the UIImage objects. For example:

let imageURLs: [URL] = self.prepareImageURLs()
let activityViewController = UIActivityViewController(activityItems: imageURLs, applicationActivities: nil)
self.present(activityViewController, animated: true, completion: nil)

您可以看到图像名称和图像属性显示在UIActivityViewController的顶部.希望对您有帮助!

You can see that the image name and the image properties are shown in the top of the UIActivityViewController. Hope it helps!

这篇关于iOS13共享表:共享UIImage时如何设置预览缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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