我试图使用UIDocumentInteractionController
实现在我的应用程序中存在的图像轻松共享。用我使用的下面的代码,一切看起来都很好。 (图像可以被转发到WHATSAPP,Viber的,Instagram的。图像可以被保存到相机胶卷等)如何区分为“UIDocumentInteractionController”选择的操作“Open in”菜单
然而,我需要一些在菜单中的操作之间进行区分。这是因为,例如Instagram只接受方形图像,并且在将图像传送给instagram之前需要进行预处理。 (Instagram的工程师应该从裁剪屏幕而不是过滤器开始应用!@#!$)否则instagram auto会自动裁剪图像的底部或右侧部分。
那么你认为有一种方法可以为不同的菜单项操作提供不同的图像吗?或者我必须首先提出一个行动控制器,并说“在instagram中打开”,“在休息时打开”?如果像whatsapp,twitter,facebook等其他应用程序拥有独家“开放式”UTI,我会走这条路。
顺便说一下,你有什么想法为什么Facebook不在列表中的showns? (我看着编辑/管理列表,它不在那里)
NSString *documentDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
//NSString *saveImagePath = [documentDirectory stringByAppendingPathComponent:@"Image.png"];
NSString *saveImagePath = [documentDirectory stringByAppendingPathComponent:@"Image.ig"];
//NSString *saveImagePath = [documentDirectory stringByAppendingPathComponent:@"Image.igo"]; // *.igo is exclusive to instagram
NSData *imageData = UIImagePNGRepresentation(capsObject.capImage);
[imageData writeToFile:saveImagePath atomically:YES];
NSURL *imageURL=[NSURL fileURLWithPath:saveImagePath];
self.docController=[[UIDocumentInteractionController alloc]init];
self.docController.delegate = self;
//self.docController.UTI = @"public.image";
self.docController.UTI = @"com.instagram.photo";
//self.docController.UTI = @"com.instagram.exclusivegram";
[self.docController setURL:imageURL];
//[self.docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
[self.docController presentOptionsMenuFromRect:CGRectZero inView:self.view animated:YES];
该功能仅在点击“在应用程序中打开”时才会调用。你有共享和动作扩展的解决方案吗? – jtmayer 2016-06-22 12:45:34