我正在开发一个应用程序,我们需要在Instagram上一次共享多个图像。我搜索了很多但找不到任何解决方案。我在Instagram上使用代码共享单个图像:
NSString *imagePath = [NSString stringWithFormat:@"%@/image.igo",[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject]];
[[NSFileManager defaultManager] removeItemAtPath:imagePath error:nil];
UIImage *sharingImg = (UIImage *)[self.watermarkedImagesArr objectAtIndex:0];
sharingImg =[self imageWithImage:sharingImg scaledToSize:CGSizeMake(sharingImg.size.width/4, sharingImg.size.height/4)];
[UIImagePNGRepresentation(sharingImg) writeToFile:imagePath atomically:YES];
NSURL *instagramURL = [NSURL fileURLWithPath:imagePath];
_docController = [UIDocumentInteractionController interactionControllerWithURL:instagramURL];
_docController.delegate = self;
_docController.UTI = @"com.instagram.exclusivegram";
self.docController.annotation = [NSDictionary dictionaryWithObject:@"Photo watermark app" forKey:@"InstagramCaption"];
[self.docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
任何帮助将不胜感激。提前谢谢。
答案 0 :(得分:2)
我认为此代码可以帮助您
NSArray* arryOfImgs = @[image1, image2, image3];
UIActivityViewController* activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:arryOfImgs
applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:^{
}];
答案 1 :(得分:0)
我不确定DocumentInteractionController,但是使用UIActivityViewController可以打开多个图像。对于Instagram共享,您需要实现自定义活动,打开要分享的程序应用程序!