在ios上分享Instagram上的图像 [英] Sharing Image on instagram in ios

查看:120
本文介绍了在ios上分享Instagram上的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,我在Instagram上分享图像,它工作得非常好。

I am having an app in which I am sharing an image on instagram and it works perfectly fine.

如截图所示。当我按下Instagram上的按钮分享时,它会在UIActivityviewcontroller中打开。

As shown in the screenshot. When I press the button share on instagram it opens up in UIActivityviewcontroller.

如果我点击Instagram上的分享并且直接将我带到本机instagram app?

Is it possible that If I click on Share on Instagram and and it takes me directly to the native instagram app?

如果用户的设备中安装了其他应用程序,那么应用程序也会因为UIActivityViewController而显示。

If the user has other apps installed in his device that apps also shows because of the UIActivityViewController.

我不想让UIActivityviewcontroller显示在Instagram上打开。

I don't want to show UIActivityviewcontroller saying "Open In Instagram".

提前致谢。

已编辑

我正在截取视图并在Instagram上分享该截图。

I am taking a screenshot of a view and sharing that screenshot on Instagram.

当我点击按钮共享它打开,如我不想要的屏幕截图所示。

When I click on a button share it opens up as shown in the screenshot which I don't want.

我使用以下代码。

NSURL *instagramURL = [NSURL URLWithString:@"instagram://"];

                if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
                {
                    CGRect rect = CGRectMake(0 ,0 , 0, 0);
                    UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
                    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];

                    UIGraphicsEndImageContext();
                    NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
                    NSString* documentsDirectory = [paths objectAtIndex:0];

                    imagename=[NSString stringWithFormat:@"ff.ig"];
                    NSString* fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imagename];
                    ////NSLog(@"%@",fullPathToFile);

                    igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", fullPathToFile]];

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


                        self.dic.annotation = [NSDictionary dictionaryWithObject:@"Image" forKey:@"InstagramCaption"];

     [self.dic presentOpenInMenuFromRect: rect    inView:self.view animated: YES ];
  }


推荐答案

self.documentInteractionController = [self setupControllerWithURL:imgurl usingDelegate:self];

self.documentInteractionController=[UIDocumentInteractionController  interactionControllerWithURL:imgurl];

self.documentInteractionController.UTI = @"com.instagram.exclusivegram";

以相同的顺序使用此代码。这里documentInteractionController是UIDocumentInteractionController.just的对象,供您参考。您只能在打开窗口中获得Instagram。

Use this code in same sequence . Here documentInteractionController is object of UIDocumentInteractionController.just for your knowledge. you will get instagram only in "open in" window.

使用igo扩展名而不是ig保存您的图像。

Save your image with igo extension instead of ig.

这样你只能在打开菜单中获得instagram选项。

By this you will only get instagram option in your "Open in" Menu.

或者,如果您想在按下按钮时直接打开Instagram,您可以传递应用程序的直接网址,它将引导您进入原生Instagram应用程序。

Or if you want to open directly instagram when you press the button you can pass the direct url of the app and it will lead you to the native instagram app.

希望它可以帮到你。

这篇关于在ios上分享Instagram上的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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