Instagram and cocos2d 2.x
A quick method to send a photo to instagram
-(void)postInstagram { AppController *app = (AppController*) [[UIApplication sharedApplication] delegate]; UIImage * screenshot = [self takeScreenShot]; NSString *savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Screenshot.igo"]; // Write image to jpeg [UIImageJPEGRepresentation(screenshot, 1.0) writeToFile:savePath atomically:YES]; NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"]; if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) { UIDocumentInteractionController *documentInteractionController = [[UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]]retain]; documentInteractionController.UTI = @"com.instagram.exclusivegram"; documentInteractionController.annotation = [NSDictionary dictionaryWithObject:@"Insert Caption here" forKey:@"InstagramCaption"]; [documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:[app navController].view animated:YES]; } }
Recent Comments