【问题标题】:UIActivityViewController image share not working for WhatsappUIActivityViewController 图像共享不适用于 Whatsapp
【发布时间】:2015-09-21 23:30:12
【问题描述】:

当我使用 UIActivityViewController 将图像数据共享到 Whatsapp 应用程序时,我收到一条警报:

此项目无法共享。请选择其他项目。

我可以将图像数据共享给除Whatsapp 之外的所有其他应用程序,有人遇到过这样的问题吗?或者谁能​​帮我解决这个问题。

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

【问题讨论】:

  • 即使我面临同样的问题并与whatsapp支持联系但到目前为止没有运气,在旧版本中它工作正常所以我的结论是iOS中whatsapp的新更新有一些问题我们无法通过 activityItems 发布。
  • 您可以在哪里绕过这个错误。 3 年后我遇到了完全相同的问题。
  • @DannyBravo 你想分享什么?

标签: ios swift uiactivityviewcontroller whatsapp


【解决方案1】:

如果您想使用 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, 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];
    }

【讨论】:

  • 我正在使用 UICollectionViewController。你能告诉我如何检测到用户点击了什么应用,我可以调用这个方法。
  • 你能分享你的代码吗?您还需要拥有最新版本的 WhatsApp。还要指定您正在测试应用的设备配置。
  • 这只是分享图片,如果我想同时分享图片和文字,那我需要做些什么改变。
猜你喜欢
  • 2014-06-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多