ios – UIActivityViewController图像共享不适用于Whatsapp

当我使用UIActivityViewController与Whatsapp应用程序共享图像数据时,我收到一条提示

This item cannot be shared. Please select a different item.

我可以将图像数据分享给除Whatsapp之外的所有其他应用程序,是否有人遇到过这样的问题?或者任何人都可以帮我解决这个问题.

如果有人想检查代码,那么如果需要,评论分享.

解决方法

如果您想使用WhatsApp共享图像,请使用以下代码
if ([[UIApplication sharedApplication] canopenURL: [NSURL URLWithString:@"whatsapp://app"]]){

        UIImage     * iconImage = [UIImage imageNamed:@"my_account.png"];
        Nsstring    * savePath  = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wai"];

        [UIImageJPEGRepresentation(iconImage,1.0) writetoFile:savePath atomically:YES];

        _documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
        _documentInteractionController.UTI = @"net.whatsapp.image";
        _documentInteractionController.delegate = self;

        [_documentInteractionController presentOpenInMenuFromrect:CGRectMake(0,0) inView:self.view animated: YES];


    } else {
        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...