【发布时间】:2016-02-15 07:07:00
【问题描述】:
- (IBAction)postToInstagram:(id)sender {
NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
CGRect rect = CGRectMake(0,0,0,0);
NSString *jpgPath=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Home_1_instgram.igo"];
UIImage *imageN = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@", jpgPath]];
// [UIImagePNGRepresentation(_imageDetail.image) writeToFile:jpgPath atomically:YES];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@",jpgPath]];
self.documentController.UTI = @"com.instagram.exclusivegram";
self.documentController = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
NSString *caption = self.catalogueImage.caption; //settext as Default Caption
//Removing pre-filled captions from mobile sharing
//http://developers.instagram.com/post/125972775561/removing-pre-filled-captions-from-mobile-sharing
self.documentController.annotation = [NSDictionary dictionaryWithObject:@"Here Give what you want to share" forKey:@"InstagramCaption"];
NSLog(@"caption: %@",caption);
[self.documentController presentOpenInMenuFromRect: rect inView: self.view animated: YES ];
}
else
{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"INSTAGRAM NOT FOUND" message:@"Please install instagram to post to instagram." delegate:nil cancelButtonTitle:nil otherButtonTitles:@"ok", nil];
[alert show];
}
}
【问题讨论】:
标签: ios objective-c instagram