问题描述
感谢这里的其他几篇文章,我已经能够成功使用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 application.
(我已经将ViewController
类设置为UIDocumentInteractionController
的delegate
,并且alloc/init
将其设置为UIDocumentInteractionController
的nonatomic/retain property
...
(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.
我该如何处理?
这是我的方法:
- (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.
推荐答案
正确的语法应为
self.docController.annotation = [NSDictionary dictionaryWithObject:self.caption.text forKey:@"InstagramCaption"];
这篇关于UIDocumentInteractionController批注属性不会将标题复制到呈现的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!