Unable to load full Facebook comment plugins inside an iOS UIWebView

可紊 提交于 2019-12-04 11:13:59

you can use this code for displaying the fb comment in iOS UIWebview

  UIWebView *fbWebview=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 320, 1505)];
  [fbWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.facebook.com/Levis"]]];

CGRect scrollViewFrame = CGRectMake(0, 0, 320, 1024);
UIScrollView  *scrollViewMain = [[UIScrollView alloc] initWithFrame:scrollViewFrame];
CGSize scrollViewContentSize = CGSizeMake(320, 1505);
[scrollViewMain setContentSize:scrollViewContentSize];
[scrollViewMain setBounces:NO];
[scrollViewMain setScrollEnabled:YES];
[scrollViewMain setShowsVerticalScrollIndicator:YES];

[scrollViewMain setBackgroundColor:[UIColor redColor]];
[scrollViewMain addSubview:fbWebview];

[self.view addSubview:scrollViewMain];

instead of "https://www.facebook.com/Levis" use your FB URL

this may help you

You need to specify a baseURL

[webView loadHTMLString:html baseURL:[NSURL URLWithString:@"http://www.example.com"]];

@Howard you can use http://www.facebook.com/plugins/comments.php?href=http://www.google.com' scrolling='yes' profile='yes' frameborder='0' style='border:none; overflow:hidden; width:300px; height:30px;' data-href='http://www.google.com' allowTransparency='true'>"

guilherme.minglini

Same problem here. The solution was not to use a local HTML file (or HTML string). Upload the HTML file to an server and use:

NSURL *url = [NSURL URLWithString:@"http://www.blablblab.com/yourfile.html"]; 
[self.webview loadRequest:[NSURLRequest requestWithURL:url]];

instead of:

[self.webview loadHTMLString:localString baseURL:nil];

I didn't discovered yet why there is a difference in the layout when the file is on a server, but when it is a local file, the height of my Facebook Comments View was always reduced to "height:160". Apparently it's because of the "all.js" facebook script (accordingly to this question).

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