【发布时间】:2014-04-02 06:38:01
【问题描述】:
我需要使用 Instagram 分享图片。我已经使用this 创建了 CLIENT ID 和 CLIENT SECRET。我在堆栈溢出中进行了搜索,但我找不到任何有用的链接。谁能帮我解决这个问题。
【问题讨论】:
-
试试下面的链接,这可能对你有帮助stackoverflow.com/questions/18242610/…
我需要使用 Instagram 分享图片。我已经使用this 创建了 CLIENT ID 和 CLIENT SECRET。我在堆栈溢出中进行了搜索,但我找不到任何有用的链接。谁能帮我解决这个问题。
【问题讨论】:
是的,您可以使用以下代码在 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 上上传图片:
【讨论】:
*** 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