0
내 앱의 Instagram에서 이미지를 공유하고 싶습니다.하지만 문제는 동일한 이미지를 두 번 공유하면 이미지가 확대되고 이미지의 일부가 엉망이되어 공유하는 코드입니다.iOS에서 인스 타 그램을 공유하는 동안 이미지가 확대되는 이유는 무엇입니까?
-(void)shareImageToInstagram
{
myview.hidden = NO;
shareImage.image = [self ChangeViewToImage:myview];
NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
CGRect cropRect=CGRectMake(0,0,306,306);
NSString *savePath=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test.igo"];
CGImageRef imageRef = CGImageCreateWithImageInRect([shareImage.image CGImage], cropRect);
UIImage *img = [[UIImage alloc] initWithCGImage:imageRef];
CGImageRelease(imageRef);
[UIImageJPEGRepresentation(img, 1.0) writeToFile:savePath atomically:YES];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@",savePath]];
self.dic.UTI = @"com.instagram.photo";
self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.dic.annotation = [NSDictionary dictionaryWithObject:kCheckOut forKey:@"InstagramCaption"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
[self.dic presentOpenInMenuFromRect: CGRectZero inView: self.view animated: YES ];
myview.hidden = YES;
}
else
{
ALERT_VIEW(@"Instagram not installed in this device!\nTo share image please install instagram.");
myview.hidden = YES;
}
}
- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate {
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
interactionController.delegate = interactionDelegate;
myview.hidden = YES;
return interactionController;
}