在ios上的instagram上共享图像

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

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

是否有可能,如果我点击在Instagram上分享,并直接带我到本地Instagram应用程序?

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

我不想显示UIActivityview控制器说“在Instagram中打开”。

提前致谢。

在这里输入图像说明

编辑

我正在拍摄一个视图的截图,并在Instagram上分享截图。

当我点击一个button共享时,它会打开,如我不想要的截图所示。

我正在使用下面的代码。

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 ]; } 

迅速

  var instagramURL = NSURL(string: "instagram://app")! if UIApplication.sharedApplication().canOpenURL(instagramURL) { var documentDirectory = NSHomeDirectory().stringByAppendingPathComponent("Documents") var saveImagePath = documentDirectory.stringByAppendingPathComponent("Image.igo") var imageData = UIImagePNGRepresentation(self.bestScoreShareView.takeSnapshot(W: 640, H: 640)) imageData.writeToFile(saveImagePath, atomically: true) var imageURL = NSURL.fileURLWithPath(saveImagePath)! docController = UIDocumentInteractionController() docController.delegate = self docController.UTI = "com.instagram.exclusivegram" docController.URL = imageURL docController.presentOpenInMenuFromRect(CGRectZero, inView: self.view, animated: true) } else { println("instagram not found") } 

从uview中取shapshot的扩展名

 extension UIView { func takeSnapshot(#W: CGFloat, H: CGFloat) -> UIImage { var cropRect = CGRectMake(0, 0, 600, 600) UIGraphicsBeginImageContextWithOptions(bounds.size, false, UIScreen.mainScreen().scale) drawViewHierarchyInRect(self.bounds, afterScreenUpdates: true) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() image.imageWithNewSize(CGSizeMake(W, H)) return image } } 

设置图像大小的扩展名

 extension UIImage { func imageWithNewSize(newSize:CGSize) ->UIImage { UIGraphicsBeginImageContext(newSize) self.drawInRect(CGRectMake(0, 0, newSize.width, newSize.height)) let newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage } } 
 self.documentInteractionController = [self setupControllerWithURL:imgurl usingDelegate:self]; self.documentInteractionController=[UIDocumentInteractionController interactionControllerWithURL:imgurl]; self.documentInteractionController.UTI = @"com.instagram.exclusivegram"; 

以相同的顺序使用此代码。 这里documentInteractionController是UIDocumentInteractionController.just的对象。 您只会在“打开”窗口中获取instagram。

用igo扩展名而不是ig来保存图像。

通过这个,你只会在你的“Open in”菜单中获得instagram选项。

或者,如果你想直接打开instagram,当你按下button,你可以通过应用程序的直接url,它会带你到本地的Instagram应用程序。

希望它可以帮助你。

你有没有检查你的图像的大小。因为它支持大于612 * 612的图像,请检查您张贴的图像的大小