我正在开发其他应用程序的共享图像,包括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 App 来分享文件而不显示菜单供选择吗?换句话说,我可以避免presentOpenInMenuFromRect
吗?
我正在使用 iOS 9,这个问题也发生在我的 Instagram 帖子中