UIWebView to display both local image and facebook comment

前端 未结 1 1637
灰色年华
灰色年华 2021-01-19 04:35

I\'m facing an issue on an UIWebView. I got a WebView which display an html string. This html string contains :

  • Html text
  • Local images
  • fb:com
相关标签:
1条回答
  • 2021-01-19 05:05

    There's a solution to use the img tag with base64 encoded image data instead of the url. That should not be a problem as you have the image locally, see the html sample.

    To test it quickly you can use the online encoding service (50kb limitation)

    The original answer is here


    And the truncated base64-sample for future reference:

    <html>
    <body>
    <div id="fb-root"></div>
    FB1
        <script>
            window.fbAsyncInit = function() {
                FB.init({
                        appId      : null,
                        channelUrl : null,
                        status     : true,
                        cookie     : true,
                        xfbml      : true 
                        });
    
            };
    
            (function(d){
             var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
             if (d.getElementById(id)) {return;}
             js = d.createElement('script'); js.id = id; js.async = true;
             js.src = "//connect.facebook.net/en_US/all.js";
             ref.parentNode.insertBefore(js, ref);
             }(document));
            </script>
    
        FB2
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUh......lAmeQ/IAAAAASUVORK5CYII=" alt="Screen Shot 2012-05-23 at 6.53.28 AM.png" />
    
        <div class="fb-comments" data-href="http://facebook.com" data-num-posts="2" data-width="470"></div>
    
    </body>
    </html>
    
    0 讨论(0)
提交回复
热议问题