【问题标题】:Sending image to whatsapp with ActivityVC使用 ActivityVC 将图像发送到 whatsapp
【发布时间】:2015-06-18 05:39:06
【问题描述】:

我正在尝试分享图片和文字。

但是当我尝试使用 whatsapp 分享时,我看不到图像并且它没有被发送(当我尝试分享到 Facebook 或邮件时,我确实看到了它......)。

怎么了?

- (void)shareImage:(UIImage *)image 
{

    NSString *sharedMsg=[NSString stringWithFormat:@"Hello world"];
    UIImage* sharedImg=image;
    NSArray* sharedObjects=[NSArray arrayWithObjects:sharedMsg, sharedImg, nil];
    UIActivityViewController *activityViewController = [[UIActivityViewController alloc]
                                                        initWithActivityItems:sharedObjects applicationActivities:nil];
    activityViewController.popoverPresentationController.sourceView = self.view;
    [self presentViewController:activityViewController animated:YES completion:nil];
}

【问题讨论】:

    标签: ios iphone share whatsapp


    【解决方案1】:

    @ozd,

    如果图片分享那么

    查看链接:Share image/text through WhatsApp in an iOS app

    &如果分享文字

    JBWhatsAppActivity 库:https://github.com/jberlana/JBWhatsAppActivity

    使用下面的代码你可以分享文本,链接..等,可能对你有帮助。

     WhatsAppMessage *whatsappMsg = [[WhatsAppMessage alloc] initWithMessage:@"Hey , I would like you to experience this fabulous app which helps you to create , store and share your MOMENTS. You can add your voice message to every photo and moments too !!!\n\nDownload the app from https://play.google.com/store?hl=en" forABID:@""];
    
        NSArray *applicationActivities = @[[[JBWhatsAppActivity alloc] init]];
        NSArray *excludedActivities    = @[UIActivityTypePrint, UIActivityTypePostToWeibo, UIActivityTypeMessage];
        NSArray *activityItems         = @[@"Hey , I would like you to experience this fabulous app which helps you to create , store and share your MOMENTS. You can add your voice message to every photo and moments too !!!\n\nDownload the app from https://play.google.com/store?hl=en", whatsappMsg];
    
        UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
        activityViewController.excludedActivityTypes = excludedActivities;
    
        [self presentViewController:activityViewController animated:YES completion:^{}];
    

    【讨论】:

    • 我看到它唯一的文字......我的问题是只有带有文字的消息或带有图像的消息。我需要他们两个
    • @ozd,你能检查上面的链接吗,我给你了? ,是不是没用!!
    猜你喜欢
    • 2023-01-30
    • 2020-01-04
    • 2022-06-14
    • 2019-12-14
    • 2015-11-02
    • 1970-01-01
    • 2015-09-27
    • 2022-10-09
    • 1970-01-01
    相关资源
    最近更新 更多