How to embed UIImage in a UIWebView

I am trying to display an Animated GIF image in a UIImageView. Since this method is shown only the first frame, I wanted to try a different approach.

UIWebView.

How can I get an Animated-GIF that is in memory (NSData) to display in a UIWebView with all frames ??

+3
source share
2 answers

Thanks to Thomas for the answer, I don’t know if this works because I managed to do it now.

Having decrypted GIF after more than a week and still not having successful results, I switched from UIImageView to UIWebView, and the following code made it work.

[self.webView loadData:gifData MIMEType:@"image/gif" textEncodingName:nil baseURL:nil];
+6
source

, - :

NSString *html = [NSString stringWithFormat:@"<img src='data:image/gif;base64,%@' />", [myData base64Value];
[myWebView loadHTMLString:html baseURL:nil]

NSData , base64, ( http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html)

edit: - gif, NSArray : http://pliep.nl/blog/2009/04/iphone_developer_decoding_an_animated_gif_image_in_objc http://blog.stijnspijker.nl/2009/07/animated-and-transparent-gifs-for-iphone-made-easy/

+3

Source: https://habr.com/ru/post/1780648/


All Articles