将Facebook / Twitter共享添加到应用程序的简单方法?

我正在寻找一种解决方案,为我的应用添加Facebook和Twitter分享按钮选项。 我当然用谷歌搜索了这个,发现了shareKit,但它不是ARC,所以只会引发很多错误,这对我没用。 还有其他选择吗? 它们需要与ARC兼容。

我想要一个可以放入的SDK,投入App ID并完成。

如果您想要简单的共享,以下内容可用于Twitter和Facebook:

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { SLComposeViewController *slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; [slComposeViewController setInitialText:@"Your text"]; [slComposeViewController addImage:[UIImage imageNamed:@"NameOfImage"]]; [self presentViewController:slComposeViewController animated:YES completion:nil]; } else { //Show alert or in some way handle the fact that the device does not support this feature } 

对于Facebook,只需将SLServiceTypeTwitter替换为SLServiceTypeFacebook即可。 必须导入“社交”框架:-)

您可以使用UIActivityViewController

 NSArray * activityItems = activityItems = @[@"title", [NSURL URLWithString:@"urlstring"]]; UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil]; [self presentViewController:activityController animated:YES completion:nil]; 

参考文献: https : //developer.apple.com/library/ios/documentation/uikit/reference/UIActivityViewController_Class/Reference/Reference.html

是使用本机iOS共享对话框: UIActivityViewController