【发布时间】:2014-07-25 20:26:27
【问题描述】:
我的应用可以使用 UIDocumentInteractionController 成功将照片上传到 Instagram,但我无法成功上传带有标题的照片。
Instagram 文档告诉您这样做:
要在照片中包含预填充的标题,您可以设置 文档交互请求上的注释属性 NSDictionary 包含键“InstagramCaption”下的 NSString。 注意:此功能将在 Instagram 2.1 及更高版本上可用。
我已经尝试了五次了。我尝试了几种不同的方法创建NSDictionary,包括使用文字语法,但我仍然无法让它工作,所以它一定是 Instagram 的问题。
这是我的代码示例,用于设置文档并在 Instagram iOS 应用中打开照片:
UIImage *screenShot = finalImage;
NSString *savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.igo"];
[UIImagePNGRepresentation(screenShot) writeToFile:savePath atomically:YES];
CGRect rect = CGRectMake(0 ,0 , 0, 0);
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.igo"];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", jpgPath]];
self.dic.UTI = @"com.instagram.photo";
self.dic.annotation = @{@"InstagramCaption" : @"Here's my caption!"};
self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
[self.dic presentOpenInMenuFromRect:rect inView:self.view animated:YES];
NSURL *instagramURL = [NSURL URLWithString:@"instagram://media?id=MEDIA_ID"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[self.dic presentOpenInMenuFromRect: rect inView: self.view animated: YES ];
} else {
NSLog(@"No Instagram Found");
}
}
注意我如何正确设置 self.dic.annotation 并遵循 Instagram 的指南。
照片在 Instagram iOS 应用中打开良好,并将成功上传到用户的个人资料,但从未包含标题。
看起来人们在 2013 年也遇到过同样的问题,但后来问题得到了解决。
【问题讨论】:
-
Instagram 不支持 InstagramCaption developers.instagram.com/post/125972775561/…
标签: ios objective-c instagram uidocumentinteraction