【问题标题】:Can Instagram be implemented into Android and iOS?Instagram 可以在 Android 和 iOS 中实现吗?
【发布时间】:2014-05-10 12:05:31
【问题描述】:

我们正在制作一个基于地图的 Android 应用程序,并且我们会在地图上的标记上弹出一个带有信息的窗口。我们集成了一个 Facebook 图标,该图标仅链接到标记的 Facebook 页面。

构建我们应用程序的公司告诉我们,由于 Instagram 尚未发布“SDK/API”,Instagram 目前无法实施?

这是真的吗,或者我们可以将“Instagram”图标从地图上的标记集成到我们的弹出信息框,以链接到所需的页面?

谁能帮忙?

【问题讨论】:

    标签: android ios facebook instagram


    【解决方案1】:

    我正在instagram 上共享图像,实现以下代码。请遵循此代码,我认为这将帮助您进行iOS 开发。

    在你的 .h file 添加一个 Delegate Method 。" UIDocumentInteractionControllerDelegate "

    并声明UIDocumentInteractionController *docController;

    在您要在 Instagram 上分享图片的.m File 中,在单击instagram 按钮操作时编写此代码。

    -(void)instagramshare_action
    {     
        NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"];
    
                if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
                {
                    NSFileManager *fileManager = [NSFileManager defaultManager] ;
                    NSArray *path=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
                    NSString *imagePath=[path objectAtIndex:0];
                    imagePath =[imagePath stringByAppendingPathComponent:@"ResizeImage"];
                    NSArray *temp=[fileManager contentsOfDirectoryAtPath:imagePath error:nil];
                    NSString *tempImgPath = [imagePath stringByAppendingPathComponent:[temp objectAtIndex:0]];
                    NSData *imgData = [NSData dataWithContentsOfFile:tempImgPath];
                    UIImage *img = [UIImage imageWithData:imgData];
    
                    CGRect rect = CGRectMake(0,0 ,612,612);
                    [img drawInRect:rect];
                    CGRect cropRect5 = CGRectMake(0,0,612,612);
                    UIGraphicsBeginImageContextWithOptions(cropRect5.size,2.0,1.0);
                    [img drawInRect:cropRect5];
                    UIImage * customScreenShot = UIGraphicsGetImageFromCurrentImageContext();
                    NSLog(@" custom sc==%@",customScreenShot);
                    UIGraphicsEndImageContext();
    
                    //saving to document directory
                    NSArray *paths10 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
                    NSString *documentsDirectory10 = [paths10 objectAtIndex:0];
                    NSString *ImageName10 = [NSString stringWithFormat:@"image.png"];
    
                    NSString* appFile = [documentsDirectory10 stringByAppendingPathComponent:ImageName10];
                    NSLog(@"appFile==%@",appFile);
                    NSData*  myImageAsData = [NSData dataWithData:UIImagePNGRepresentation(customScreenShot)];
                    [myImageAsData writeToFile:appFile atomically:YES];
    
                    //getting image(png format) from document directory and again saving with ig format
                    NSString *ImageName1 =@"image.png";
                    NSString *getImagePath =[documentsDirectory10 stringByAppendingPathComponent:ImageName1];
    
                    UIImage *img1 = [UIImage imageWithContentsOfFile:getImagePath];
    
                    NSData *data = UIImageJPEGRepresentation(img1, 1.0);
                    UIImage *images = [[UIImage alloc] initWithData:data];
    
                    NSLog(@"img==%@",images);
                    CGRect rect2 = CGRectMake(0,0,612,612);
    
                    [img1 drawInRect:rect2];
    
                    NSString *ImageName = [NSString stringWithFormat:@"Image.ig"];
    
                    NSString* appFile2 = [documentsDirectory10 stringByAppendingPathComponent:ImageName];
                    NSLog(@"appFile==%@",appFile2);
                    NSData*  myImageAsData2 = [NSData dataWithData:UIImagePNGRepresentation(img1)];
                    NSLog(@"myimagedata==%@",myImageAsData2);
                    NSURL *imageUrl = [NSURL fileURLWithPath:appFile2];
                    [myImageAsData2 writeToFile:appFile2 atomically:YES];
                    docController = [[UIDocumentInteractionController alloc] init];
                    docController.delegate = self;
                    [docController retain];
                    docController.UTI = @"com.instagram.photo";
                    [docController setURL:imageUrl];
                    CGRect rect4=CGRectMake(0,0,320,480);
                    [docController presentOpenInMenuFromRect:rect4 inView:self.view animated:YES];
                }
                else
                {
                    UIAlertView *errorToShare = [[UIAlertView alloc] initWithTitle:@"Instagram unavailable " message:@"You need to install Instagram in your device in order to share this image" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                    [errorToShare show];
                    [errorToShare release];
                }
    }
    
    
    Important : You have to install Instagram App on your device otherwise i write the code for showing alert. And for checking with `instagram` you have to create a account on `instagram`
    

    我认为这会对您有所帮助,为 instagram 实现 iOS 。 :)

    【讨论】:

    • 我们不想分享和图像,这就是问题所在。我们想分享人民的页面。这可能吗?干杯!
    猜你喜欢
    • 1970-01-01
    • 2011-08-10
    • 2014-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多