3

我使用了下面给出的代码。但它只将图像发布到 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];
4

1 回答 1

1

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

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];
于 2013-04-13T05:27:59.827 回答