有谁知道我如何在 iPhone 应用程序中包含 Facebook“点赞按钮”。我尝试在 UIWebView
中调用 iframe,但这不起作用。
最佳答案
看看这段不错的代码: http://angelolloqui.blogspot.com/2010/11/facebook-like-button-on-ios.html
将 FBLikeButton
类添加到您的 View 中:
FBLikeButton *likeButton = [[FBLikeButton alloc] initWithFrame:CGRectMake(0, 372, 320, 44)
andUrl:@"http://www.facebook.com/pages/De-Zilk/108209735867960"];
非常感谢 Angel García Olloqui
编辑:很高兴添加...奖励积分:
如果您使用上述方法,该网页的格式不适用于 iPhone。您可以做的是运行一些 JavaScript 代码来删除所有令人不安的 div。使用这个(长句):
[_webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"javascript:document.getElementsByClassName('uiButton')[2].style.visibility='hidden';var child1 = document.getElementById('standard_status');var parent1 = document.getElementById('login_form');parent1.removeChild(child1);var child2 = document.getElementById('pageheader');var parent2 = document.getElementById('booklet');parent2.removeChild(child2);document.getElementById('loginform').style.width = '200px';var child3 = document.getElementById('reg_btn_link');var parent3 = document.getElementsByClassName('register_link')[0];parent3.removeChild(child3);var child4 = document.getElementById('signup_area');var parent4 = document.getElementById('login_form');parent4.removeChild(child4);var child5 = document.getElementsByClassName('mbm')[0];var parent5 = document.getElementById('loginform');parent5.removeChild(child5);var child6 = document.getElementsByClassName('reset_password form_row')[0];var parent6 = document.getElementById('loginform');parent6.removeChild(child6);var child7 = document.getElementsByClassName('persistent')[0];var parent7 = document.getElementById('loginform');parent7.removeChild(child7);"]];
您可以将它放在 FBDialog
Facebook 类的委托(delegate)方法 webViewDidFinishLoad
中。
关于iphone - 在 iPhone 应用程序中添加 Facebook Like 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2783803/