Ios 直接使用UIDocumentINteractionController自动打开WhatsApp,而不显示其他应用程序

Ios 直接使用UIDocumentINteractionController自动打开WhatsApp,而不显示其他应用程序,ios,objective-c,image,uidocumentinteraction,socialshare,Ios,Objective C,Image,Uidocumentinteraction,Socialshare,我正在开发其他应用程序的共享图像,包括WhatsApp。 我正在使用这段代码,它是有效的 if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]]){ UIImage *image = [self processImage:sender]; NSString *savePath = [NSHomeDirectory() stringByAppendin

我正在开发其他应用程序的共享图像,包括
WhatsApp
。 我正在使用这段代码,它是有效的

if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]]){
    UIImage *image = [self processImage:sender];

    NSString *savePath  = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wai"];

    [UIImageJPEGRepresentation(image, 1.0) writeToFile:savePath atomically:YES];


    _documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
    _documentInteractionController.delegate = self;
    _documentInteractionController.UTI = @"net.whatsapp.image";
    [_documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];


}else {
    [self showAlertTitle:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed."];
}
问题是,当我运行此代码时,
documentInteractionController
会显示其他类似的选项应用程序,因此我必须先选择WhatsApp,然后再打开WhatsApp应用程序

我可以选择Whatsapp应用程序来共享文件,而不显示选择菜单吗?换句话说,我是否可以避免
presentOpenMenuFromRect


我使用的是iOS 9,我的Instagram帖子也出现了这个问题。

是的。你可以编写代码。运行代码后,执行以下操作

步骤:1在Info.plist中添加LSApplicationQueriesSchemes


步骤:2在项目中添加whatsapp。

我不能使用此方法,因为我必须发送图像数据,而不是文本。据我所知,自定义URL方案还不支持图像数据。如何在代码中实现共享扩展方法?我认为共享扩展是指documentInteractionController方法。在步骤1:我已经尝试了这些代码,实际上它与我以前使用的代码相同,但是,在我可以在步骤2中启动whatsApp之前,它首先启动了documen交互菜单:我已经在项目中添加了whatsApp