我试图分享图片和文字。
但是当我尝试使用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];
}
答案 0 :(得分:0)
@ozd,
如果图片分享则
请参阅链接:Share image/text through WhatsApp in an iOS app
&安培; 如果共享文字
JBWhatsAppActivity Library:https://github.com/jberlana/JBWhatsAppActivity
使用以下代码您可以分享Text,Link..etc,对您有所帮助。
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:^{}];