gpt4 book ai didi

iphone - UIWebView 同时显示本 map 片和 facebook 评论

转载 作者:可可西里 更新时间:2023-11-01 05:57:24 25 4
gpt4 key购买 nike

我在 UIWebView 上遇到问题。我有一个显示 html 字符串的 WebView。此 html 字符串包含:

  • HTML 文本
  • 本 map 片
  • Facebook :评论

起初我只有 Html + 本地镜像,所以我使用的是众所周知的方法:

NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
[webview loadHTMLString:htmlString baseURL:baseURL];

一切都很完美。但后来我不得不实现 facebook 评论 http://developers.facebook.com/docs/reference/plugins/comments/

因为我的旧 BaseURL 不再适用于 facebook,所以我尝试加载

NSURL *baseURL = [NSURL URLWithString:@"http://www.facebook.com/"];

这使我的 facebook 可以正常工作,但本地镜像不会显示在 webview 中,即使是绝对路径也是如此。

如有任何帮助,我们将不胜感激。感谢您的宝贵时间

最佳答案

有一个解决方案是使用 img 标签和 base64 编码的图像数据而不是 url。这应该不是问题,因为您在本地拥有图像,请参阅 html sample

要快速测试它,您可以使用在线编码 service(50kb 限制)

原答案是here


以及截断的 base64 样本以供将来引用:

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

关于iphone - UIWebView 同时显示本 map 片和 facebook 评论,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10605698/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com