WhatsApp图像共享iOS [英] WhatsApp image sharing iOS

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

问题描述

我正在开发一个iOS应用程序,我必须在我的应用程序上分享WhatsApp上的图像。我找到了这段代码,但它仅处理文本共享 https://github.com/jberlana/JBWhatsAppActivity

I am developing an iOS application in which i have to share image on WhatsApp from my application. I found this code but it deals with only text sharing https://github.com/jberlana/JBWhatsAppActivity

推荐答案

使用 documentationInteractionController 可以实现。
最近我使用下面的代码来共享图像从我们的应用程序到whatsApp,Line,WeChat但是当你点击WhatsApp图标时,你就是导航 WhatsApp 来自您应用的应用,您必须手动返回应用。在ImageSharing之后,这不再重定向。

That can be Possible using documentationInteractionController. Recently I have done this using bellow code to share image From our App to whatsApp, Line, WeChat but while you click on WhatsApp icon, then you are navigation WhatsApp app from you app and you must return you app manually. That does not redirect again after ImageSharing.

在.h文件中: -

@interface ViewController : UIViewController<UIDocumentInteractionControllerDelegate>
{
}

@property(nonatomic,retain) UIDocumentInteractionController *documentationInteractionController;

.m文件中的

- (IBAction)bocClick:(UIButton *)sender {


    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,     NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];

    NSString *getImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"]; //here i am fetched image path from document directory and convert it in to URL and use bellow


    NSURL *imageFileURL =[NSURL fileURLWithPath:getImagePath];
    NSLog(@"imag %@",imageFileURL);

    self.documentationInteractionController.delegate = self;
    self.documentationInteractionController.UTI = @"net.whatsapp.image";
    self.documentationInteractionController = [self setupControllerWithURL:imageFileURL usingDelegate:self];
    [self.documentationInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];


}

- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL

                                               usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate {



    self.documentationInteractionController =

    [UIDocumentInteractionController interactionControllerWithURL: fileURL];

    self.documentationInteractionController.delegate = interactionDelegate;



    return self.documentationInteractionController;

}

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

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