Dumoko Dumoko -4 years ago 69
iOS Question

Pasting image in sms through UIPasteBoard

What I'm trying to do is to paste some images from my app in SMS.

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSString *imagefile = [[NSBundle mainBundle]
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:imagefile];

if (fileExists){
UIImage *ui = [[UIImage alloc] initWithContentsOfFile:imagefile];
pasteboard.image = ui;
[ui release];

In debug mode I find out that the image DOES exist, and it DOES go to pasteboard (I checked it my introducing an imageview with the image from pasteboard, and it's the necessary one).

After saving to clipboard, I call

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:"]];

it does pop-up, but when i tap to "textfield" there, no Paste button shows.
Can somebody point at my mistake?
Or does it make sense doing so? I mean, is it possible to send a image through Default iPhone Message App?

Answer Source

"Paste" action will be shown only if the paste board contains the supported item for the current object(here Text Field) you tapped. It seems that you are adding only an image to the paste board. Text Field doesn't support images. So "Paste" action doesn't show up.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download