iOS与WhatsApp共享图像和文本 [英] iOS share image AND text to WhatsApp

查看:274
本文介绍了iOS与WhatsApp共享图像和文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经google了,并获得了一些解决方案,似乎唯一可行的方法是通过 UIDocumentInteractionController 。我发现只能分享文字的结果,也找到了只分享图片的结果。

I have googled, and get some solutions, it seems the only possible way is thru UIDocumentInteractionController. I have found the result that able to share text ONLY, also found result that share image ONLY.

但是我想要的是分享 BOTH

我知道这个问题可能会重复,我只想说清楚,这是截图。 ..

I know this question may be duplicated, I just wanted to make it clear, here is the screenshot...

(这是从Android共享的)

推荐答案

您可以使用UIActivityViewController来共享图像,文本或URL。这是一个小例子:

You can use UIActivityViewController to share image , text or URL .Here is a small example :

NSString *textToShare = @"Enter your text to be shared";
UIImage * image = [UIImage imageNamed:@"imagename"];

NSArray *objectsToShare = @[textToShare, image];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];


[self presentViewController:activityVC animated:YES completion:nil];

运行上面的代码并选择要分享的应用程序,如果您希望也可以通过其他媒介分享。这是苹果'
的默认股票方法

Run the above code and select whats app to share if you want you can share by other mediums also . This is apple' s default share method

这篇关于iOS与WhatsApp共享图像和文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆