3

I am having some confusion here...

how do i display gif for my iPhone app? (I mean there are various articles which i found, but every tutorial just didn't have a complete solution)

There are many solutions between which i am confused.

Should i split gif into different frames using an online tool and then display it in UIImageView using animation?

Or should i display gif into a UIWebview?

Or should i use this article? http://blog.stijnspijker.nl/2009/07/animated-and-transparent-gifs-for-iphone-made-easy/

This article is pretty nice but it cuts the rest of the frames making the image smaller in size. Moreover, i am not able to know how its working so i dont know the reason of frames getting cut.

Please note that after i display the gif, i want to copy the gif and then paste it in my in-app mail window.

Need help plz. Thanks!

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

1 Answers1

3

UIWebView is a the biggest memory-hog in UIKit and should be avoided whenever possible. Converting gif to series of png files and displaying it using UIImageView with animated image sequence is best you can do.

But to use it in the mail window, you would have to keep the gif too. Now how you want to insert it depends on if you want it to be an attachment or a html img. I would suggest the second option, and hosting the gif somewhere online, then doing:

[mailController setMessageBody:@"<img src=\"http://path.to/image.gif\" />" isHTML:YES];

And if you want to add it as attachment:

NSData *imageData = [[NSData alloc] initWithContentsOfFile:pathToGifFile];
[mailController addAttachmentData:imageData mimeType:@"image/gif" fileName:@"pic.gif"];
[imageData release];
Filip Radelic
  • 26,607
  • 8
  • 71
  • 97
  • the gif, i want to add is a local one. Also, i want to make the user copy it from my app and then paste it in the mail window. So, i'll have to show the gif by the paste button. Is it possible? – mayuur Aug 08 '11 at 12:19
  • Sure, you could accomplish that, but I would honestly suggest you reconsider it because it sounds like bad user experience for iOS. If you are going to open the mail window for user, you should populate it too instead of making them paste stuff from your app. What exactly are you trying to do? – Filip Radelic Aug 08 '11 at 12:29
  • oh sory for that. Actually i will be pasting it in not only my in-app mail but even in the Mail app in iphone or wherever mail window appears. actually i was testing it in the in-app mail so i wrote like that. My mistake. actually i need to make user copy images from my app and then paste images in his/her mail window just like emoticons. can u help me for doing that???? – mayuur Aug 08 '11 at 12:42
  • I have added another answer with code you need to do it, enjoy. – Filip Radelic Aug 08 '11 at 13:51