在我的应用程序中,我使用UIActivityViewController
在 Facebook 和 Twitter 中共享文本。但如何分享不同的文字?请提前帮助..谢谢
我使用了这段代码:
NSString *posturl2=@"twittwrer and facebook ";
UISimpleTextPrintFormatter *printData = [[UISimpleTextPrintFormatter alloc]
initWithText:@"Hi"];
NSArray *Itemsarray = @[posturl2,printData];
UIActivityViewController *activityController = [[UIActivityViewController alloc]initWithActivityItems:Itemsarray applicationActivities:nil];
[self presentViewController:activityController
animated:YES completion:nil];
想要这样
答案 0 :(得分:-2)
导入社交框架
#import <Social/Social.h>
然后致电
- (void)shareOnFacebookWithText:(NSString *)textToShare {
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:textToShare];
[self presentViewController:controller animated:YES completion:nil];
}
}
- (void)shareOnTwitterWithText:(NSString *)textToShare {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *tweetSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:textToShare];
[self presentViewController:tweetSheet animated:YES completion:nil];
}
}