2013-04-02 44 views
7

在我的應用程序中,我在Instagram上分享圖像。它在我的應用程序中運行良好。在ios的Instagram上分享帶有圖片的文字

我正在使用以下代碼。

@property (nonatomic, retain) UIDocumentInteractionController *dic;  

CGRect rect = CGRectMake(0 ,0 , 0, 0); 
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0); 
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
UIGraphicsEndImageContext(); 
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test.igo"]; 

NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", jpgPath]]; 
// NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", screenshot]]; 

self.dic.UTI = @"com.instagram.photo"; 
self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self]; 
self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile]; 
[self.dic presentOpenInMenuFromRect: rect inView: self.view animated: YES ]; 


- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate { 
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL]; 
interactionController.delegate = interactionDelegate; 
return interactionController; 
} 

現在我還想分享一些文字與圖像。

如下圖所示。在「編寫標題」中,我想爲例如一些默認的自定義文本。 「分享這張照片」。

我該怎麼做?

在此先感謝...

enter image description here

編輯

我從我的應用程序打開Instagram的分享圖像,它工作正常。

但我可以檢查用戶是否已成功共享它嗎?

表示我想在用戶成功分享圖像時在我的數據庫中執行某些操作。

我該怎麼做?

回答

14

我得到了我的答案。只是添加了一條線,它爲我工作。

self.dic.annotation = [NSDictionary dictionaryWithObject:@"Here Give what you want to share" forKey:@"InstagramCaption"]; 

謝謝...

+0

嘿,這不適合我。 –

+0

添加文本和圖像的任何其他設置..? –

3

它還在http://instagram.com/developer/iphone-hooks/

記錄的官方文檔中包含有你的照片預填充的標題,你可以設置在註釋屬性文檔交互請求到包含關鍵字「InstagramCaption」下的NSString的NSDictionary。注意:此功能將在Instagram 2.1及更高版本上提供。

+3

截至2015年8月,Instagram無視InstagramCaption註釋。請參閱:http://developers.instagram.com/post/125972775561/removing-pre-filled-captions-from-mobile-sharing – joshrl

1

您不能再與Instagram或Facebook共享預填文本。

只有圖像/屏幕截圖可以通過UIDocumentInteractionController共享。

相關問題