iphone - 在 iPhone 应用程序中添加 Facebook Like 按钮

标签 iphone facebook button facebook-like

有谁知道我如何在 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/

相关文章:

iphone - 应用程序未运行时处理推送通知

PHP header 重定向问题

android - 如何从另一个应用程序开始 android facebook 应用程序聊天

java - 初始化变量的 NullPointerException?

qt - 如何创建类似 Material Design 的自定义元素?

iphone - 模态视图和触摸开始

iphone - 使用 NSDictionary 的崩溃错误 - Iphone SDK

iphone - TableViewDataSource 文件的运行时错误已分离

Facebook jQuery 插件

delphi - 如何知道按钮被点击了多少次?