【问题标题】:Can we post the image in instagram using iOS application我们可以使用 iOS 应用程序在 Instagram 中发布图像吗
【发布时间】:2014-04-02 06:38:01
【问题描述】:

我需要使用 Instagram 分享图片。我已经使用this 创建了 CLIENT ID 和 CLIENT SECRET。我在堆栈溢出中进行了搜索,但我找不到任何有用的链接。谁能帮我解决这个问题。

【问题讨论】:

标签: ios instagram


【解决方案1】:

是的,您可以使用以下代码在 Instagram 上发布图片

-(IBAction)uploadimage:(UIButton*)sender
{

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

    if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
    {

       CGSize size=CGSizeMake(612, 612);

       UIImage *TajImage = [UIImage imageNamed:@"gujarat.jpg"];

       UIImage *image = [self scale:TajImage toSize:size];

       NSString  *jpgPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"instagram.igo"];


       [UIImageJPEGRepresentation(image, 1.0) writeToFile:jpgPath atomically:YES];

       CGRect rect = CGRectMake(0 ,0 , 0, 0);

       NSURL *fileURL = [NSURL fileURLWithPath:jpgPath];

       self.docFile = [UIDocumentInteractionController interactionControllerWithURL:fileURL];

       self.docFile.delegate = self;

       [self.docFile setUTI:@"com.instagram.exclusivegram"];

       [self.docFile setAnnotation:@{@"InstagramCaption" : @"Gujarti Lion,Girnar,India"}];

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

       [[UIApplication sharedApplication] openURL:instagramURL];

    }
}

在 Instagram 上上传图片:

【讨论】:

  • 用你的一些代码更新了我的代码,它工作了,但问题是它把我带到我的 Instagram 时间线而不是添加照片视图,必须注册吗?重定向到张贴图片?我还想知道在开发阶段是否也必须在 Instagram 上注册我的应用程序?
  • ' [[UIApplication sharedApplication] openURL:instagramURL];'这是额外的删除它解决了问题
  • 我的做法一模一样,但出现错误*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType URL]: unrecognized selector sent to instance 0x147d67c0' *** First throw call stack: (0x2698cf87 0x340ebc77 0x2699237d 0x26990259 0x268c1d68 0x2a450e89 0x275e3065 0x27688277 0x892eb5 0x88d3fd 0x89455b 0x895885 0x347c9e25 0x347c9b78) libc++abi.dylib: terminating with uncaught exception of type NSException
猜你喜欢
  • 1970-01-01
  • 2013-12-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多