在 iPhone 应用程序中添加 Facebook Like 按钮 [英] Adding the Facebook Like Button in an iPhone App

查看:31
本文介绍了在 iPhone 应用程序中添加 Facebook Like 按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道我将如何在 iphone 应用程序中包含一个 facbeook喜欢按钮".我尝试在 UIWebView 内调用 iframe,但这不起作用.

Does anyone know how I would include a facbeook "like button" in an iphone app. I tried calling the iframe inside of a UIWebView but that doesn't work.

推荐答案

看看这段漂亮的代码:http://angelloqui.blogspot.com/2010/11/facebook-like-button-on-ios.html

FBLikeButton 类添加到您的视图中:

Add the FBLikeButton class to your view:

FBLikeButton *likeButton = [[FBLikeButton alloc] initWithFrame:CGRectMake(0, 372, 320, 44)       
andUrl:@"http://www.facebook.com/pages/De-Zilk/108209735867960"];

非常感谢 Angel García Olloqui

Thanks a lot Angel García Olloqui

很高兴添加...奖励积分:
如果您使用上述方法,则该网页的格式不适用于 iPhone.您可以做的是运行一些 JavaScript 代码来删除所有令人不安的 div.用这个(长句):

Nice to add... For bonus points:
If you use above method the webpage is not well formatted for an iPhone. What you can do is run some JavaScript code to remove all the disturbing divs. Use this (long sentence):

  [_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 类的委托方法 webViewDidFinishLoad 中.

You can place it in the delegate method webViewDidFinishLoad from the FBDialog Facebook class.

这篇关于在 iPhone 应用程序中添加 Facebook Like 按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆