将Facebook/Twitter共享添加到应用程序的简单方法? [英] Simple way to add Facebook/Twitter share to app?
问题描述
我正在寻找一种解决方案,以在我的应用程序中添加Facebook和Twitter共享按钮选项.我当然已经用谷歌搜索了,发现了shareKit,但是它不是ARC,所以会抛出很多错误,这对我没有用.还有其他选择吗?它们必须与ARC兼容.
I'm looking for a drop in solution to add a Facebook and Twitter share button option to my app. I've googled this of course, and found shareKit but it's non-ARC so just throws lots of errors, which is of no use to me. Any other options? they need to be ARC compatible.
我想要一个可以插入,放入App ID并完成的SDK.
I want a SDK that I can drop in, throw in the App ID's and be done.
推荐答案
如果您希望简单共享,则可以将以下内容用于Twitter和Facebook:
If you want simple sharing, the following can be used for Twitter and 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.必须导入社交"框架:-)
For Facebook, simply replace SLServiceTypeTwitter with SLServiceTypeFacebook. The "Social" framework must be imported :-)
这篇关于将Facebook/Twitter共享添加到应用程序的简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!