[英]Simple way to add Facebook/Twitter share to app?
我正在尋找將我的應用程序添加Facebook和Twitter共享按鈕選項的解決方案。 我已經用谷歌搜索了,發現了shareKit,但是它不是ARC,所以會拋出很多錯誤,這對我沒有用。 還有其他選擇嗎? 它們需要與ARC兼容。
我想要一個可以插入,放入應用程序ID並完成的SDK。
如果要簡單共享,則可以將以下內容用於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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.