在 iOS 中在 Instagram 上分享多张图片
Share multiple images on Instagram in iOS
我正在开发一个应用程序,我们需要在其中一次在 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];
如有任何帮助,我们将不胜感激。提前致谢。
我不确定 DocumentInteractionController,但使用 UIActivityViewController 可以打开多个图像。对于 Instagram 分享,您需要实施自定义 activity,它会打开 instgram 应用程序进行分享!
我认为这段代码可以帮到你
NSArray* arryOfImgs = @[image1, image2, image3];
UIActivityViewController* activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:arryOfImgs
applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:^{
}];
我正在开发一个应用程序,我们需要在其中一次在 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];
如有任何帮助,我们将不胜感激。提前致谢。
我不确定 DocumentInteractionController,但使用 UIActivityViewController 可以打开多个图像。对于 Instagram 分享,您需要实施自定义 activity,它会打开 instgram 应用程序进行分享!
我认为这段代码可以帮到你
NSArray* arryOfImgs = @[image1, image2, image3];
UIActivityViewController* activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:arryOfImgs
applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:^{
}];