Reputation: 29896
How can one copy images to the UIPasteboard?
I have only seen examples for text.
Upvotes: 5
Views: 6338
Reputation: 678
Actually, you can just simply use these code:
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = @"my string";
pasteboard.image = [UIImage imageNamed:@"my image"];
Upvotes: 1
Reputation: 1016
use this ..... here newImage is UIImage.
UIPasteboard *pasteBoard = [UIPasteboard pasteboardWithName:UIPasteboardNameGeneral create:NO];
pasteBoard.persistent = YES;
NSData *data = UIImagePNGRepresentation(newImage);
[pasteBoard setData:data forPasteboardType:(NSString *)kUTTypePNG];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:00"]];
Upvotes: 1
Reputation: 55544
If you look at Apple's Documentation for UIPasteboard, you see that you can use the 'setImage:` method to copy images to the pasteboard, eg:
[[UIPasteboard generalPasteboard] setImage:myImage];
or if you want to add multiple images:
[[UIPasteboard generalPasteboard] setImages:[NSArray arrayWithObjects:myFirstImage, mySecondImage, nil]];
or if you already have the array of images:
[[UIPasteboard generalPasteboard] setImages:myImagesArray];
(where all the above variables that begin with my
should be substituted for the ones in your code)
Upvotes: 14