Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIDocumentInteractionController批注属性不将标题复制到显示的应用程序_Ios_Objective C_Ios7_Instagram_Uidocumentinteraction - Fatal编程技术网

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

Ios UIDocumentInteractionController批注属性不将标题复制到显示的应用程序,ios,objective-c,ios7,instagram,uidocumentinteraction,Ios,Objective C,Ios7,Instagram,Uidocumentinteraction,多亏了这里的其他几篇文章,我成功地使用Instagram iPhone挂钩打开Instagram,并从我的应用程序中成功地将照片呈现给它 我已经使我的ViewController类成为UIDocumentInteractionController的委托,并分配/初始化UIDocumentInteractionController的非原子/保留属性 然而,我放在document controller annotation属性中的NSDictionary中的密钥似乎不会保留到Instagram中——

多亏了这里的其他几篇文章,我成功地使用Instagram iPhone挂钩打开Instagram,并从我的应用程序中成功地将照片呈现给它

我已经使我的ViewController类成为UIDocumentInteractionController的委托,并分配/初始化UIDocumentInteractionController的非原子/保留属性

然而,我放在document controller annotation属性中的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

应该使用正确的语法

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

我不知道有关发布到instagram的任何信息,但您正在将注释设置为字典,其中对象是MyApp,关键是标题文本。你不需要把它倒过来吗?真的吗?我对NSDictionary不太熟悉,但我在网上看到的示例有对象的名称和键的标题。。。肯定是错的。。IDK。我只是想把它们倒过来,但还是没用…你是对的。。。正确的语法应该是作为对象的标题,键应该是@InstagramCaptionGlad,我可以帮助:。。。只是在黑暗中拍摄。通常像这样的API会有键的常量,并且您的自定义数据应该在对象中。这样,它就能准确地知道要在字典中查找哪些键。您知道是否有其他键可以使用此注释进行更新吗?请注意,Instagram不再支持预填充标题功能: