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