I want to copy image and text (both) to UIPasteBoard. Is it possible to copy both the text and image.
Here I can copy image only or text only . How to copy both ?
My code for copy image is as follows,
UIPasteboard *pasteBoard = [UIPasteboard pasteboardWithName:UIPasteboardNameGeneral create:NO];
pasteBoard.persistent = YES;
NSData *data = UIImagePNGRepresentation(newImage);
[pasteBoard setData:data forPasteboardType:(NSString *)kUTTypePNG];
Thanks in advance !!!!!
Here is my code and it is working perfectly on my device.
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.persistent = NO;
NSMutableDictionary *text = [NSMutableDictionary dictionaryWithCapacity:1];
[text setValue:captionLabel.text forKey:(NSString *)kUTTypeUTF8PlainText];
NSMutableDictionary *image = [NSMutableDictionary dictionaryWithCapacity:1];
[image setValue:gratitudeImageView.image forKey:(NSString *)kUTTypePNG];
pasteboard.items = [NSArray arrayWithObjects:image,text, nil];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With