将照片发布到Instagram时,没有显示标题,它只是空的。
Instagram已禁用此功能吗? 如果不是,我的代码可能不正确。
以下是我尝试过的方法:
-(void)shareImageOnInstagram:(UIImage *)image
{
//Must be 612x612
NSString* imagePath = [NSString stringWithFormat:@"%@/instagramShare.igo", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]];
[[NSFileManager defaultManager] removeItemAtPath:imagePath error:nil];
UIImage *instagramImage = image;
[UIImagePNGRepresentation(instagramImage) writeToFile:imagePath atomically:YES];
NSLog(@"Image Size >>> %@", NSStringFromCGSize(instagramImage.size));
self.docController.annotation = [NSDictionary dictionaryWithObject:@"mmm" forKey:@"InstagramCaption"];
self.docController=[UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:imagePath]];
self.docController.delegate = self;
self.docController.UTI = @"com.instagram.exclusivegram";
[self.docController presentOpenInMenuFromRect: self.view.frame inView:self.view animated:YES ];
}
谢谢!
答案 0 :(得分:0)
您在尝试设置注释后初始化了UIDocumentInteractionController
。你必须切换这两行,如下所示:
self.docController=[UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:imagePath]];
self.docController.annotation = [NSDictionary dictionaryWithObject:@"Posted using #Truthly" forKey:@"InstagramCaption"];
self.docController.delegate = self;
self.docController.UTI = @"com.instagram.exclusivegram";
[self.docController presentOpenInMenuFromRect: self.view.frame inView:self.view animated:YES ];