0
我想從我的應用程序Instagram上分享圖像它的工作相當好,但問題來了,當我第二次分享相同的圖像圖像變得放大和圖像的一些部分變得混亂在這裏是我的共享代碼。爲什麼在iOS上分享instagram時圖像變焦?
-(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;
}