我正在使用UIDocumentInteractionController
與其他應用程序共享在我的應用程序中拍攝的圖像。 當您使用此功能與Instagram分享時,您可以使用包含密鑰@"InstagramCaption"
的字典設置註釋屬性,該字典將預先填寫評論。UIDocumentInteractionController註釋屬性使用
我想知道是否有可能與其他應用程序做到這一點,如果是的話,字典的關鍵是什麼。
我主要對消息應用程序和郵件應用程序(標題和正文)感興趣,但是如果您知道允許進行文檔交互的其他應用程序的密鑰,它也會很棒(Facebook,Twitter,WhatsApp ,Path,Tumblr,...)。
這裏是我做的:
- (void)openImageInOtherApp:(UIImage *)image
{
NSError *error = nil;
NSURL *tempDirectoryURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
NSURL *imageURL = [tempDirectoryURL URLByAppendingPathComponent:@"image.jpeg" isDirectory:NO];
NSData *imageData = UIImageJPEGRepresentation(image, 0.8);
BOOL saveSucceeded = [imageData writeToURL:imageURL options:NSDataWritingAtomic error:&error];
if (!saveSucceeded || error) {
NSLog(@"Error : Saving image %@ at URL %@ failed with error : %@", image, imageURL, error);
return;
}
UIDocumentInteractionController *interactionController = [[UIDocumentInteractionController alloc] init];
interactionController.delegate = self;
interactionController.URL = imageURL;
NSString *comment = @"A test comment"; // A comment that will be sent along with the image
if (comment != nil && comment.length > 0) {
interactionController.annotation = @{@"someKey": comment};
}
self.interactionController = interactionController;
BOOL canOpenDocument = [interactionController presentOptionsMenuFromRect:self.view.bounds inView:self.view animated:YES];
NSLog(@"canOpenDocument : %@", canOpenDocument ? @"YES" : @"NO");
}
然後系統視圖出現在那裏我可以選擇一個應用程序,可以打開該文件。
它只是在浪費時間 –
您能否請您提供您當前的代碼樣本? – Yuyutsu
我剛剛用我使用的代碼編輯了我的答案。代碼不是問題,但我不知道如何設置註釋詞典來發送評論與圖像。 – deadbeef