无法将图像发布到Instagram应用程序

时间:2012-11-20 06:27:34

标签: iphone objective-c

我正在开发一个需要将图片发布到Instagram的应用。我遵循了这些link1和  link2

然而,这对我不起作用。之后,我发现了这个链接: How to share an image on Instagram in iOS?

我根据此进行了更改,但它没有发布图像。这是我的代码:

CGRect rect = CGRectMake(0 ,0 , 100, 100);

UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);

[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];

UIGraphicsEndImageContext();

NSString *staticPath = [[NSBundle mainBundle] pathForResource:@"JB" ofType:@"igo"];
NSString *path_font = [staticPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *fileAppend = [[NSString alloc] initWithFormat:@"file://"];
path_font = [[NSString alloc] initWithFormat:@"%@%@", fileAppend, path_font];

NSLog(@"path_font----%@",path_font);
NSLog(@"filepath_static image----%@",filepath_static);

NSURL *igImageHookFile = [[NSURL alloc] initWithString:path_font];

NSLog(@"igImageHookFile url is---%@",igImageHookFile);

self.dic.UTI = @"com.instagram.photo";

self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];

self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];

[self.dic presentOpenInMenuFromRect: rect    inView: self.view animated: YES ];

任何建议都会非常感激。

1 个答案:

答案 0 :(得分:1)

https://github.com/coryalder/DMActivityInstagram确实提供了一个非常好的例子,可以通过UIActivity Control将图像发布到Instagram,但您当然只能使用发布部分。

希望有所帮助。