Reputation: 49
I used the code given below. But it only post image to 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];
Upvotes: 3
Views: 1052
Reputation: 1951
Add social framework. Import in your view controller.
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];
Upvotes: 1