我使用了下面给出的代码。但是它仅将图像发布到facebook。

UIImage *image = [UIImage imageNamed:@"testimage.png"];
    NSString *caption = @"Gud Mng";
    NSArray *activityItems = @[image, caption];
    // Initialize Activity View Controller
    UIActivityViewController *vc = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
    // Present Activity View Controller
    [self presentViewController:vc animated:YES completion:nil];

最佳答案

添加社交框架。导入您的视图控制器。

SLComposeViewController *socialVc=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
NSData *data = UIImageJPEGRepresentation(self.defaultImageView.image, 1.0);
[socialVc addImage:[UIImage imageWithData:data]];


[socialVc setInitialText:[NSString    stringWithFormat:@"%@",self.captionTextFeild.text]];
[socialVc addURL:[NSURL URLWithString:@"via www.coderit.com"]];
[self.navigationController presentViewController:socialVc animated:YES completion:nil];

关于iphone - 如何在iOS 6.0中使用社交框架从iPhone应用程序在Facebook上共享图像?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15984532/

10-08 20:40