Instagram Instagram标题无法正常工作 [英] Instagram InstagramCaption not working

查看:155
本文介绍了Instagram Instagram标题无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码可以在Instagram上分享文章.

I have below code for sharing article on Instagram.

-(void) shareInstagram {
    NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
    if([[UIApplication sharedApplication] canOpenURL:instagramURL]) //check for App is install or not
    {
        UIImage *instaImage = mImg.image;
        NSData *imageData = UIImagePNGRepresentation(instaImage); //convert image into .png format.
        NSLog(@"imageData.leeee===%d", imageData.length);
        if (imageData.length<=100) {
            [self.view makeToast:localize(@"instaErr2") duration:2.0 position:@"bottom"];
        } else {
            NSFileManager *fileManager = [NSFileManager defaultManager];//create instance of NSFileManager
            NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //create an array and store result of our search for the documents directory in it
            NSString *documentsDirectory = [paths objectAtIndex:0]; //create NSString object, that holds our exact path to the documents directory
            NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"insta.igo"]]; //add our image to the path
            [fileManager createFileAtPath:fullPath contents:imageData attributes:nil]; //finally save the path (image)
            NSLog(@"image saved");

            CGRect rect = CGRectMake(0 ,0 , 0, 0);
            UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
            [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
            UIGraphicsEndImageContext();
            NSString *fileNameToSave = [NSString stringWithFormat:@"Documents/insta.igo"];
            NSString  *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:fileNameToSave];
            NSLog(@"jpg path %@",jpgPath);
            NSString *newJpgPath = [NSString stringWithFormat:@"file://%@",jpgPath];
            NSLog(@"with File path %@",newJpgPath);
            NSURL *igImageHookFile = [[NSURL alloc]initFileURLWithPath:newJpgPath];
            NSLog(@"url Path %@",igImageHookFile);

            self.documentController.UTI = @"com.instagram.exclusivegram";
            self.documentController = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
            self.documentController=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];

            NSString *globalString;

            if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"PoPinFrom"] isEqualToString:@"user"]) {
                globalString = [NSString stringWithFormat:@"%@ @ %@\n\nhttp://egkw.com/ArticleDetail.aspx?id=%@\n\niPhone : %@\n\nAndroid : %@", [[productDetailsArray objectAtIndex:0] valueForKey:@"Title"], localize(@"appName"), [[productDetailsArray objectAtIndex:0] valueForKey:@"Id"], localize(@"appStoreLink"), localize(@"playStoreLink")];
            } else {
                globalString = [NSString stringWithFormat:@"%@ @ %@\n\nhttp://egkw.com/ArticleDetail.aspx?id=%@\n\niPhone : %@\n\nAndroid : %@", [[productDetailsArray objectAtIndex:0] valueForKey:@"Title"], localize(@"appName"), [[productDetailsArray objectAtIndex:0] valueForKey:@"Id"], localize(@"appStoreLink"), localize(@"playStoreLink")];
            }

            globalString = [NSString stringWithFormat:@"%@\n\n#EGKW", globalString];
            NSLog(@"insta==globalString==%@", globalString);
            self.documentController.annotation=[NSDictionary dictionaryWithObjectsAndKeys:globalString, @"InstagramCaption", nil];
            // self.documentController.annotation = [NSDictionary dictionaryWithObject:globalString forKey:@"InstagramCaption"];
            [self.documentController presentOpenInMenuFromRect:rect inView: self.view animated:YES];
        }
    }
    else
    {
        NSLog (@"Instagram not found");
        DTAlertView *myAl = [DTAlertView alertViewWithTitle:localize(@"err001") message:localize(@"instaErr") delegate:nil cancelButtonTitle:localize(@"dismiss") positiveButtonTitle:nil];
        [myAl setDismissAnimationWhenButtonClicked:DTAlertViewAnimationSlideTop];
        [myAl showWithAnimation:DTAlertViewAnimationSlideBottom];
    }
}

此代码之前运行良好.但是,当我注意到时,我发现字幕没有显示在Instagram中.经过研究,我改变了

This code was working fine earlier. However when I noticed, I see that caption is not showing in Instagram. After research I changed

 self.documentController.annotation=[NSDictionary dictionaryWithObjectsAndKeys:globalString, @"InstagramCaption", nil];

self.documentController.annotation = [NSDictionary dictionaryWithObject:globalString forKey:@"InstagramCaption"];

但仍然无法正常工作.

知道发生了什么问题吗?

Any idea what is going wrong?

Instagram是否更改了Facebook之类的任何政策?

推荐答案

Instagram现在已使用交互控制器删除了对标题字段的填写.

Instagram has now removed the filling in of the caption field using the interaction controller.

从他们那里看到此博客帖子

See this blog post from them

Instagram开发者博客

这篇关于Instagram Instagram标题无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆