我们正在制作基于地图的Android应用,我们会在地图上的标记上弹出信息。我们已经整合了一个Facebook图标,该图标只链接到标记的Facebook页面。
由于Instagram尚未发布“SDKs / API”,我们正在建立我们的应用程序,告知Instagram目前无法实施吗?
这是真的还是我们可以将“Instagram”图标从地图上标记链接到所需页面的弹出信息框中集成?
有人可以帮忙吗?
答案 0 :(得分:2)
我正在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
的实施有帮助。 :)
答案 1 :(得分:0)
显然,开发人员可以将Instagram集成到他们的Applications.Study this链接中,您就可以将其集成。