Want to copy a gif image from my app to the in-app mail window. How do i do that?

南笙酒味 提交于 2019-12-21 05:43:11

问题


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!


回答1:


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];


来源:https://stackoverflow.com/questions/6981783/want-to-copy-a-gif-image-from-my-app-to-the-in-app-mail-window-how-do-i-do-that

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!