Ios 如何区分为“UIDocumentInteractionController”选择的操作;在“中打开”;菜单

Ios 如何区分为“UIDocumentInteractionController”选择的操作;在“中打开”;菜单,ios,objective-c,instagram,social-networking,uidocumentinteraction,Ios,Objective C,Instagram,Social Networking,Uidocumentinteraction,我正在尝试使用UIDocumentInteractionController实现应用程序中存在的图像的轻松共享。使用下面的代码,一切看起来都很好。(图像可转发至whatsapp、viber、instagram。图像可保存至照相/摄像卷等) 但是,我需要区分菜单中的一些操作。这是因为Instagram只接受方形图像,在我将图像提供给Instagram之前需要进行预处理。(Instagram工程师应该从裁剪屏幕启动应用程序,而不是从过滤器屏幕启动应用程序!@#!$)否则Instagram会自动裁剪

我正在尝试使用
UIDocumentInteractionController
实现应用程序中存在的图像的轻松共享。使用下面的代码,一切看起来都很好。(图像可转发至whatsapp、viber、instagram。图像可保存至照相/摄像卷等)

但是,我需要区分菜单中的一些操作。这是因为Instagram只接受方形图像,在我将图像提供给Instagram之前需要进行预处理。(Instagram工程师应该从裁剪屏幕启动应用程序,而不是从过滤器屏幕启动应用程序!@#!$)否则Instagram会自动裁剪图像的底部或右侧部分

那么,您认为有没有一种方法可以为不同的菜单项操作提供不同的图像?还是我必须先展示一个actioncontroller,然后说“在instagram中打开”、“在rest中打开”?如果像whatsapp、twitter、facebook这样的其他应用程序都有专用的“开放式”UTIs,我就会这么做

顺便问一下,你知道为什么facebook不在名单上吗?(我查看了“编辑/管理”列表。它不在那里)


您需要实现委托的方法

- (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application{
   NSLog(@"Will beginsending to application");
// Detect if the application is instagram

  if(![application isEqualToString:@"com.instagram.photo"]){
   //Make the custom implementation of your image.
    UIImage     * iconImage = [self prepareImage];
   //save it to documents path
    NSString    * savePath  = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Image.ig"];
    [UIImageJPEGRepresentation(iconImage, 1.0) writeToFile:savePath atomically:YES];
   // change the URL of your file
    controller.URL=[NSURL fileURLWithPath:savePath];

   }
}

仅当点击“在应用程序中打开”时,才会调用此函数。您是否有共享和操作扩展的解决方案?
- (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application{
   NSLog(@"Will beginsending to application");
// Detect if the application is instagram

  if(![application isEqualToString:@"com.instagram.photo"]){
   //Make the custom implementation of your image.
    UIImage     * iconImage = [self prepareImage];
   //save it to documents path
    NSString    * savePath  = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Image.ig"];
    [UIImageJPEGRepresentation(iconImage, 1.0) writeToFile:savePath atomically:YES];
   // change the URL of your file
    controller.URL=[NSURL fileURLWithPath:savePath];

   }
}