xcode ios 5 和 ios 6 的 Facebook 集成
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14064899/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Facebook integration for ios 5 & ios 6
提问by user1673099
I want to integrate Facebook both for ios 5 and ios 6.
我想为 ios 5 和 ios 6 集成 Facebook。
I have the knowledge of integrating facebook in individual ios(i.e ios 5 or ios 6), but have no idea of how to support facebook for both ios 5 and ios 6.
我知道在个人 ios(即 ios 5 或 ios 6)中集成 facebook 的知识,但不知道如何为 ios 5 和 ios 6 支持 facebook。
In the other words, how to integrate facebook both for ios 5 and ios 6 ? or what is the common way to support this in both ios?
换句话说,如何为 ios 5 和 ios 6 集成 facebook ?或者在两个ios中支持这个的常用方法是什么?
Thanks
谢谢
回答by Zen
Well if you want to use the facebook integration within iOS6, and if the iOS version is lower than 6 , you want to use the Facebook SDK for iOS, you can check for the availability of the integrated Facebook service class in the Social Framework
. Also you would have to import the Social Framework
for it.
那么如果你想在iOS6中使用facebook集成,并且如果iOS版本低于6,你想使用iOS的Facebook SDK,你可以在Social Framework
. 你也必须Social Framework
为它导入。
#import<Social/Social.h>
You can check for the availability of the integrated facebook service by something like this in the buttonAction
method
您可以在buttonAction
方法中通过类似的方式检查集成的 facebook 服务的可用性
- (void)buttonAction:(id)sender
{
//Check for availability of Facebook integration and use its view controller to share on Facebook
if(NSClassFromString(@"SLComposeViewController") != nil) {
SLComposeViewController *fbController=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
//Use fbController for sharing
} else {
// Service not available
}
}
else{
// Use your code for sharing on iOS versions other than 6.x to authenticate and get an access token.
}
}
Hope it helped.
希望它有所帮助。
回答by user1673099
回答by Gajendra K Chauhan
If you have xcode 4.5 or later. Using social framework,you can implement Facebook on iOS. Also check FB and Twitter integration for iPhone tutorial.Visit http://kmithi.blogspot.co.uk/2012/10/integrating-facebook-and-twitter-in-ios.html
如果您有 xcode 4.5 或更高版本。使用社交框架,您可以在 iOS 上实现 Facebook。还要检查 iPhone 教程的 FB 和 Twitter 集成。访问http://kmithi.blogspot.co.uk/2012/10/integrating-facebook-and-twitter-in-ios.html