UIDocumentInteractionController注释属性不会将标题复制到显示的应用程序

时间:2014-01-09 06:27:24

标签: ios objective-c ios7 instagram uidocumentinteraction

感谢这里的其他几个帖子,我已成功地使用Instagram iPhone挂钩打开Instagram,并通过我的应用成功地将照片呈现给它。

(我已将ViewController课程设为delegate UIDocumentInteractionControlleralloc/init编辑nonatomic/retain property UIDocumentInteractionController ..

但是,我放入文档控制器注释属性NSDictionary中的关键字似乎不会转移到Instagram上 - 标题区域只是空的.. 。

有没有人知道如何处理这个?

这是我的方法:

- (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。

谢谢你提前!

~Jesse

1 个答案:

答案 0 :(得分:0)

正确的语法应该是

self.docController.annotation = [NSDictionary dictionaryWithObject:self.caption.text forKey:@"InstagramCaption"];