Ios UIDocumentInteractionController注释属性用法
我正在使用Ios UIDocumentInteractionController注释属性用法,ios,objective-c,iphone,uikit,sharing,Ios,Objective C,Iphone,Uikit,Sharing,我正在使用UIDocumentInteractionController与其他应用程序共享在我的应用程序中拍摄的图像。 使用此选项与Instagram共享时,可以使用包含键@“InstagramOption”的字典设置注释属性,该键将预先填充注释 我想知道其他应用程序是否可以这样做,如果可以的话,字典的键是什么 我主要对messages应用程序和mail应用程序(标题和正文)感兴趣,但是如果你知道其他允许文档交互的应用程序的键,那也很棒(Facebook、Twitter、WhatsApp、Pat
UIDocumentInteractionController
与其他应用程序共享在我的应用程序中拍摄的图像。
使用此选项与Instagram共享时,可以使用包含键@“InstagramOption”
的字典设置注释属性,该键将预先填充注释
我想知道其他应用程序是否可以这样做,如果可以的话,字典的键是什么
我主要对messages应用程序和mail应用程序(标题和正文)感兴趣,但是如果你知道其他允许文档交互的应用程序的键,那也很棒(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");
}
然后出现系统视图,我可以在其中选择可以打开文件的应用程序。阅读API开发人员文档(Facebook、Twitter、WhatsApp、Path、Tumblr等) 范例
//组合对话框参数
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Sharing Tutorial", @"name",
@"Build great social apps and get more installs.", @"caption",
@"Allow your users to share stories on Facebook from your app using the iOS SDK.", @"description",
@"https://developers.facebook.com/docs/ios/share/", @"link",
@"http://i.imgur.com/g3Qc1HN.png", @"picture",
nil];
这可能会帮助您:)UIDocumentInteractionController不会神奇地支持所有这些平台。其中一些使用的API将为您提供更多选项 查看如何为Messages应用程序创建彩信
用于发送带有图像附件的电子邮件。这只是浪费时间。请将您当前的代码作为示例。我刚刚用我使用的代码编辑了我的答案。虽然代码不是问题,但我只是不知道如何设置注释字典以随图像一起发送注释。您阅读了吗谢谢,但这并不能回答我的问题。我不想使用API在Facebook或Twitter上分享,而是使用UIDocumentInteractionController。另外,正如我提到的,我想知道如何为Messages应用程序和Mail应用程序做到这一点,其余的只是一个额外的功能。