2013-04-02 15 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のを開封しておりますし、それが正常に動作します。

しかし、それは可能ですか?ユーザーがそれを正常に共有しているかどうかを確認できますか?

手段ユーザーが画像を正常に共有したときに、自分のDBで何らかの操作を実行したい。

どうすればいいですか?

答えて

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で画像/スクリーンショットのみを共有できます。

関連する問題