【发布时间】:2015-02-23 11:50:19
【问题描述】:
我正在尝试使用UIDocumentInteractionController 为我的应用程序中存在的图像实现轻松共享。使用我正在使用的以下代码,一切看起来都很好。 (图片可以转发到whatsapp、viber、instagram。图片可以保存到相机胶卷等)
但是,我需要区分菜单中的一些操作。这是因为例如 Instagram 只接受方形图像,并且在我将图像提供给 instagram 之前需要进行预处理。 (Instagram 工程师应该从裁剪屏幕而不是过滤器屏幕启动应用程序!@#!$)否则 instagram 会自动裁剪图像的底部或右侧。
那么您认为有一种方法可以为不同的菜单项操作提供不同的图像吗?还是我必须先展示一个动作控制器并说“在 Instagram 中打开”、“在休息时打开”?如果其他应用程序,如 whatsapp、twitter、facebook 有独家的“开放式”UTI,我会走那条路。
顺便问一下,您知道为什么 facebook 没有显示在列表中吗? (我查看了编辑/管理列表。它不存在)
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];
【问题讨论】:
标签: ios objective-c instagram social-networking uidocumentinteraction