问题描述
感谢此处的其他几个帖子,我已经成功地使用Instagram iPhone挂钩打开Instagram,并通过我的应用成功地将照片呈现给它。
Thanks to a couple other posts here , I've successfully be able to use the Instagram iPhone hooks to open Instagram and present it with a photo successfully from my appliaction.
(我已经 ViewController
类委托
UIDocumentInteractionController
, alloc / init
'ed a nonatomic / retain property
of UIDocumentInteractionController
...
(I've made my ViewController
class a delegate
of UIDocumentInteractionController
, and alloc/init
'ed a nonatomic/retain property
of UIDocumentInteractionController
...
但是,我放入我放置的 NSDictionary
中的密钥在文档控制器注释属性将似乎不会转移到Instagram - 标题区域只是空...
However, the key that I put into my NSDictionary
that I place in the document controller annotation property will not seem to carry over to Instagram - the caption area is just empty...
有没有人有任何关于如何处理这个问题的想法???
Does anyone have any idea about how to deal with this ???
这是我的方法:
- (void) uploadImageToInstagram:(UIImage *)imageToUpload {
NSLog(@"postToInstagramInBackground");
NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
// Upscale to 612x612
imageToUpload = [self upscaleImage:imageToUpload];
// Get JPG + IGO Format
NSString *savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/generate.igo"];
[UIImageJPEGRepresentation(imageToUpload, 1.0) writeToFile:savePath atomically:YES];
// Paths
NSURL *imageURL = [NSURL fileURLWithPath:savePath];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@",savePath]];
// Setup DocController
self.docController.UTI = @"com.instagram.photo";
self.docController = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.docController.annotation = [NSDictionary dictionaryWithObject:@"MyApp" forKey:self.caption.text];
[self.docController setURL:imageURL];
[self.docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES ];
}
else {
NSLog(@"Instagram not installed in this device!\nTo share image please install Instagram.");
}
}
这里有一些方法叫做我没有包括,一个升级图像以确保其612x612,一个设置文件控制器的文件URL。
There are a few methods that are called here that I haven't included, one that upscales the image to make sure its 612x612, and one setups the file url for the document controller.
谢谢提前!
~Jesse
推荐答案
正确的语法应该是
self.docController.annotation = [NSDictionary dictionaryWithObject:self.caption.text forKey:@"InstagramCaption"];
这篇关于UIDocumentInteractionController注释属性不会将标题复制到显示的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!