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];
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];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.