我正在寻找一种解决方案,为我的应用添加Facebook和Twitter分享按钮选项。我当然用Google搜索了这一点,并发现了shareKit,但它不是ARC,所以只会抛出很多错误,这对我没用。还有其他选择吗?它们需要与ARC兼容。
我想要一个可以插入的SDK,然后输入App ID并完成。
答案 0 :(得分:3)
如果您想要简单分享,可以在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即可。必须导入“社交”框架: - )
答案 1 :(得分:1)
您可以使用UIActivityViewController
:
NSArray * activityItems = activityItems = @[@"title", [NSURL URLWithString:@"urlstring"]];
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityController animated:YES completion:nil];
答案 2 :(得分:0)
是使用原生iOS共享对话框:UIActivityViewController