3

I wanted to show a gif so what i did was that i split my gif and showed it in a animation for UIImageView using this link.

http://iphonenativeapp.blogspot.com/2011/03/how-to-show-animation-in-iphoneipad-app.html

Now, i want to make the user copy that gif and paste it in the mail app.

If i used the array which contained all the split images of gif then 4-5 images get pasted in the mail app.

Please help me paste the gif. Thanks!

Filip Radelic
  • 26,607
  • 8
  • 71
  • 97
mayuur
  • 4,736
  • 4
  • 30
  • 65

4 Answers4

7

Gonna copy/paste my own answer from a similar question.

NSString *gifPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"volleyball.gif"];
NSData *gifData = [[NSData alloc] initWithContentsOfFile:gifPath];
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
[pasteboard setData:gifData forPasteboardType:@"com.compuserve.gif"];
[gifData release];

Edit just noticed you asked these 2 similar questions yourself.

Community
  • 1
  • 1
Filip Radelic
  • 26,607
  • 8
  • 71
  • 97
  • thanks so much!!!! Its working now. Actually i had tried this thing yesterday but it dint work, as i had messed up in the forPasteboardType section. I had become so desperate i posted it again... Btw, Can u tell me what is "com.compuserve.gif" ???? Or what should be used as parameter for "forPasteboardType" ????? – mayuur Aug 09 '11 at 05:46
0

FWIW, animated gifs appear to work with email in the new share sheets in iOS 6, which would automatically populate the gif in an email if the user selects mail:

NSString *gifPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"volleyball.gif"];
NSData *gifData = [[NSData alloc] initWithContentsOfFile:gifPath];
NSArray *activityItems = [NSArray arrayWithObjects:@"Here is an awesome body for the email.",gifData,nil];
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityController.completionHandler = ^(NSString *activityType, BOOL completed){
  // item was shared!
  // you can check if it was email (or another type, like facebook or twitter) in the *activityType.
  // completed is YES if they actually shared it, if they canceled, completed will be NO.
};
[navigationController presentViewController:activityController animated:YES completion:nil];
Jesse
  • 10,370
  • 10
  • 62
  • 81
0

Although you can use HTML based email -- for example:

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSString *emailBody = @"<p><b>Hello World</b></p>";                         
[picker setMessageBody:emailBody isHTML:YES];

You can't insert inline images as you would typically in HTML. Inline images in HTML email use separate MIME parts that are referenced via a content-id element from the body of the message. MFMailComposeViewController doesn't give you control over the MIME structure of the message and thus doesn't let you add inline referenced content parts.

Embedding image data into <img> tags as base64 will sometimes work -- it depends on the email client and browser used to render it -- but it's not broadly portable.

memmons
  • 40,222
  • 21
  • 149
  • 183
-1

As iOS does not support the animated GIF format, I don't think it is possible to copy/paste the gif in the mail app. However, you can try attaching the gif file (not the split images) & composing a new email using MFMailComposeViewController. If you open the attachment on a non-iOS device, you should be able to see the animated GIF.

HTH,

Akshay

Akshay
  • 5,747
  • 3
  • 23
  • 35
  • no, i tried it in safari browser for iphone. I opened a URL containing gif, copied it and then pasted it in the mail window. And it was working fine. So, it should be possible copying gifs normally too! – mayuur Aug 08 '11 at 13:34
  • In that case, you should paste the gif file on the UIPasteBoard, rather than the array of split images. You will have to see how you allow the user to copy the gif, say by providing a copy button or adding a custom UIMenuItem when the user long presses on your UIImageView. – Akshay Aug 08 '11 at 14:15