Ios 设置UIDocumentInteractionController';后,Instagram照片上不会显示标题;s注释属性
我的应用程序可以使用Ios 设置UIDocumentInteractionController';后,Instagram照片上不会显示标题;s注释属性,ios,objective-c,instagram,uidocumentinteraction,Ios,Objective C,Instagram,Uidocumentinteraction,我的应用程序可以使用UIDocumentInteractionController将照片成功上传到Instagram,但我无法成功上传带有标题的照片 Instagram文档告诉您这样做: 要在照片中包含预填充的标题,可以设置 文档交互请求上的批注属性 NSDictionary包含键“InstagramOption”下的NSString。 注:Instagram 2.1及更高版本将提供此功能 我已经试过五次了。我尝试过创建一个NSDictionary多种不同的方法,包括使用文字语法,但我仍然无法让
UIDocumentInteractionController
将照片成功上传到Instagram,但我无法成功上传带有标题的照片
Instagram文档告诉您这样做:
要在照片中包含预填充的标题,可以设置
文档交互请求上的批注属性
NSDictionary包含键“InstagramOption”下的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年也遇到了同样的问题,但问题解决了。我刚刚解决了这个问题
我所做的只是将我的语句移动到我定义的self.dic.annotation
下面的语句中:
self.dic = [UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
上面的语句返回了UIDocumentInteractionController
的一个新实例,显然没有设置它的任何属性
编辑:我建议不要使用我发布的原始代码,除非您愿意进行更改。我刚刚注意到有两条语句返回一个UIDocumentInteractionController
实例,它们都紧挨着彼此:
self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.dic = [UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
这段代码来自一个教程,所以我不能保证它的质量。如果你想使用它,一定要逐行分析,这样你就不会像我一样陷入困惑
编辑2:
这是最后一个工作完美的代码示例。您应该能够使用此选项而不会出现错误:
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 = [UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
self.dic.UTI = @"com.instagram.photo";
self.dic.annotation = [NSDictionary dictionaryWithObject:@"Enter your caption here" forKey:@"InstagramCaption"];
[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");
}
截至2015年8月,Instagram将忽略InstagramOption注释。请参阅:Instagram不支持InstagramOption