How to copy UIImage data to clipboard/UIPasteboard? And how do I test it?

pradeepa picture pradeepa · Jul 11, 2011 · Viewed 8.9k times · Source

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?

Answer

omz picture omz · Jul 11, 2011

It's a lot easier:

[UIPasteboard generalPasteboard].image = imgView.image;

To get the image out again:

UIImage *image = [UIPasteboard generalPasteboard].image;