2016-02-15 20 views
2
- (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]; 
} 
} 

回答

0

我已經在你的代碼改變的東西:

你應該使用com.instagram.photo

- (IBAction)postToInstagram:(id)sender { 

if ([self schemeAvailable:@"instagram://app"]) 
{ 
    CGRect rect = CGRectMake(0,0,0,0); 
    NSString *jpgPath=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Home_1_instgram.igo"]; 
    UIImage *imageN = [UIImage imageNamed:@"IMG_1304.PNG"]; 

    [UIImagePNGRepresentation(imageN) writeToFile:jpgPath atomically:YES]; 
    NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@",jpgPath]]; 
    self.documentController.UTI = @"com.instagram.photo"; 

    self.documentController = [UIDocumentInteractionController interactionControllerWithURL:igImageHookFile]; 
    NSString *caption = @"YourCaption"; //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]; 
    } 
} 
+0

我仍然遇到同樣的問題Mohamad Frahand我仍然看到instagram的過濾器部分而不是修剪部分 –

+0

但我已經在我的代碼中嘗試了您的操作,然後將它發送到此處! 你可以上傳你的代碼嗎? – Mohamad

+0

我正在使用NSURL而不是schemeAvailable,其他所有內容都是相同的NSURL * instagramURL = [NSURL URLWithString:@「instagram:// app」]; 如果([[UIApplication的sharedApplication] canOpenURL:instagramURL]){ 我 –

1

我找到了解決的辦法。在iOS Instagram直接發送用戶到過濾器部分,而在android中,用戶被定向到裁剪部分。它在Instagram iPhone Hook中被提及。 謝謝

相關問題