2013-04-02 27 views
7

Trong Ứng dụng của tôi, tôi chia sẻ hình ảnh trên Instagram. Nó hoạt động tốt trong ứng dụng của tôi.Chia sẻ văn bản với Hình ảnh trên Instagram trong ios

Tôi đang sử dụng mã sau.

@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; 
} 

Bây giờ tôi cũng muốn chia sẻ một số văn bản với hình ảnh.

Như được hiển thị trong Hình ảnh bên dưới. Trong "Viết chú thích", tôi muốn một số văn bản tùy chỉnh mặc định cho ví dụ. "Chia sẻ hình ảnh này".

Tôi làm cách nào để thực hiện việc này?

Cảm ơn trước ...

enter image description here

Sửa

Tôi mở Instagram từ ứng dụng của tôi để chia sẻ hình ảnh và nó hoạt động tốt.

Nhưng tôi có thể kiểm tra xem người dùng đã chia sẻ thành công hay không?

Có nghĩa là tôi muốn thực hiện một số hành động trong DB của mình khi người dùng chia sẻ thành công hình ảnh.

Tôi làm cách nào để thực hiện việc này?

Trả lời

14

Tôi đã nhận được câu trả lời của mình. Chỉ cần thêm một dòng và nó đã làm việc cho tôi.

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

Thanks ...

+0

này, điều này không hiệu quả đối với tôi. –

+0

bất kỳ cài đặt nào khác để thêm văn bản và hình ảnh ..? –

3

Nó cũng được ghi nhận trong các tài liệu chính thức tại http://instagram.com/developer/iphone-hooks/

Để đưa một chú thích điền sẵn với ảnh của bạn, bạn có thể thiết lập thuộc tính chú thích trên yêu cầu tương tác tài liệu với một NSDictionary có chứa một NSString dưới khóa "InstagramCaption". Lưu ý: tính năng này sẽ khả dụng trên Instagram 2.1 trở lên.

+3

Tính đến tháng 8 năm 2015, Instagram đang bỏ qua chú thích InstagramCaption. Xem: http://developers.instagram.com/post/125972775561/removing-pre-filled-captions-from-mobile-sharing – joshrl

1

Bạn không được phép chia sẻ văn bản được điền sẵn với Instagram hoặc Facebook.

Chỉ hình ảnh/ảnh chụp màn hình mới có thể được chia sẻ qua UIDocumentInteractionController.

Các vấn đề liên quan