iOS:Facebook评论插件手机不断重新加载 [英] iOS: Facebook Comments Plugin mobile keeps reloading
问题描述
< html>
< body>
< div id =fb-root>< / div>
< script>(function(d,s,id){
var js,fjs = d.getElementsByTagName(s)[0];
if(d.getElementById(id) return;
js = d.createElement(s); js.id = id;
js.src =//connect.facebook.net/en_US/all.js#xfbml=1;
fjs.parentNode.insertBefore(js,fjs);
}(document,'script','facebook-jssdk'));< / script> data-width =240data-width =数据显示-面= 假 >< / DIV>
< div class =fb-commentsdata-href =http://www.heretheweb.comdata-num-posts =5data-width =470> DIV>
< body>
< / html>
星期一的第一个实现在四个平台(两个模拟器(iOS 4和iOS 5))都是成功的, iPhone 3G iOS4和iPhone 4 iOS 5.
星期二,我一直在开发这个,最后我的自定义UIWebView在前三个没有问题。但是在iPhone 4(iOS 5)上,网页视图一遍又一遍地重新加载相同的网页,导致评论框永远不会出现。这个URL是这样的:
我不知道我在做什么错了,我已经清理了uiWebView委托方法,我已经检查了断点所有的方法我可以覆盖没有...网页在开头加载,然后循环尝试加载上述URL ...
好吧解决了
对于一些奇怪而奇怪的原因,有时在iPhone 4(而不是模拟器,iPhone 3G或iPad 2)中加载评论web部分时,会尝试重新加载一次(Cache-Control头设置为max -age = 0,所以它一直强制重新加载)
解决方法是检查UIWebViewNavigationType,如果它等于UIWebViewNavigationTypeReload,shouldStartLoadWithRequest:返回NO。
真的很棘手¬¬
Recently I have been trying to integrate Facebook Social Plugins into a custom UIWebView in iOS for commenting a webpage. I have added the Like Button as well as the Comments plugin. Here is the HTML code I load into the web view:
<html>
<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-href="http://www.heretheweb.com" data-send="false" data-layout="button_count" data-width="240" data-show-faces="false"></div>
<div class="fb-comments" data-href="http://www.heretheweb.com" data-num-posts="5" data-width="470"></div>
<body>
</html>
The first implementation on Monday was sucessfull in 4 platforms, both simulators (iOS 4 and iOS 5), iPhone 3G iOS4 and iPhone 4 iOS 5. On Tuesday, I kept developing this and I ended up with my custom UIWebView working with no problems in the first three. But on iPhone 4 (iOS 5) the web view kept reloading the same web page over and over again, resulting in the comment box never appearing. That URL is this:
I don't know what I am doing wrong really, I have cleaned the uiWebView delegate methods, I have check with breakpoints ALL the methods I could override. Nothing... The webpage gets loaded at the beginning, and then it loops trying to load the above URL...
Ok... solved. For some strange and weird reason, sometimes when loading the comments web part ONLY in iPhone 4 (not simulator, iPhone 3G or iPad 2) it tries to reload once and once again (the Cache-Control header is set to max-age=0, so it keeps forcing the reload)
The solution was to check the UIWebViewNavigationType, if it's equal to UIWebViewNavigationTypeReload, shouldStartLoadWithRequest: returns NO.
It was REALLY tricky ¬¬
这篇关于iOS:Facebook评论插件手机不断重新加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!