如何将UIImage数据复制到剪贴板/UIPasteboard?我该如何测试它?
我尝试使用以下代码通过单击菜单中的“复制”项将图像数据复制到 UIPasteboard
。
UIPasteboard *gpBoard = [UIPasteboard generalPasteboard];
[[gpBoard setData:UIImageJPEGRepresentation(imgView.image, 1.0) forPasteboardType:UIPasteboardTypeListImage];
我必须为 forPasteboardType
: 发送哪个参数,以及复制数据后如何测试?
I tried to use the following code to copy the Image data to UIPasteboard
on click of the Copy item in the menu.
UIPasteboard *gpBoard = [UIPasteboard generalPasteboard];
[[gpBoard setData:UIImageJPEGRepresentation(imgView.image, 1.0) forPasteboardType:UIPasteboardTypeListImage];
Which parameter i have to send for forPasteboardType
:, and how to test after copying the data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这要容易得多:
要再次取出图像:
It's a lot easier:
To get the image out again:
我尝试了上述方法,但由于某种原因,它在 iOS 7,8 上时好时坏。有时有效,有时无效,即系统不显示“粘贴”选项。
这对我来说在所有设备和所有 iOS 上都一致有效
I tried the above and for some reason it's a hit and miss on iOS 7,8. Sometimes it works and sometimes it doesn't i.e. system doesn't show "Paste" option.
This worked for me consistenly on all devices and all iOS
斯威夫特:
Swift: