ios - 在 whatsapp 上分享视频 - objective c

标签 ios objective-c video ios7.1 whatsapp

在 iOS 7.1.1 上,我可以通过此代码在 Whatsapp 上分享图像..

if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]]){

        UIImage     * iconImage = [UIImage imageNamed:@"image.png"];
        NSString    * savePath  = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wai"];

        [UIImageJPEGRepresentation(iconImage, 1.0) writeToFile:savePath atomically:YES];

        self.docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
        self.docController.UTI = @"net.whatsapp.image";
        self.docController.delegate = self;
        //[self.docController setAnnotation:@{@"WhatsappCaption" : @"https://itunes.apple.com/us/app/epic-ar/id535122470?ls=1&mt=8"}];

        [self.docController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:appDelegate.window.rootViewController.view animated: YES];

}

但我也想分享视频,我按照Wahtsapp tutorial上的教程进行操作

但是视频路径的代码怎么可能呢?

我的意思是,UIImage 对象的替代对象是什么来显示视频?

另外,我可以分享“链接”吗?

谢谢,

最佳答案

我花了一段时间,但我把这些碎片拼凑起来了

引用文献:Share image/text through WhatsApp in an iOS app //http://www.whatsapp.com/faq/en/iphone/23559013

//---NEXT LINE OF CODE IS OPTIONAL AND NOT RECOMMENDED, BUT YOU CAN USE IT TO TEST TO SEE IF THEY HAVE THE WHATSAPP INSTALLED
//    if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]]){

    NSString    * savePath  = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wam"];

    savePath = [[NSBundle mainBundle] pathForResource:@"Movie" ofType:@"m4v"];


    _documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
    _documentInteractionController.UTI = @"net.whatsapp.movie";
    _documentInteractionController.delegate = (id)self;

    [_documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:self.view animated: YES];

这只是为了回答您的主要问题:在 whatsapp 上分享视频

关于ios - 在 whatsapp 上分享视频 - objective c,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24161321/

相关文章:

ios - ios 8 中的 voip 应用程序是否有新要求?

ios - 暂停/继续解析 PEGKit 解析器?

c++ - OpenCV - 用于跟踪红色的 HSV 值范围

ios - 如何从模式设置为仅时间的 UIDatePicker 获取日期

ios - 如何在AppDelegate中隐藏和显示UIViewController按钮? - swift

ios - 在 Objective-C 中使用 pragma 标记的正确方法是什么?

javascript - 通过 Websockets 进行 WebRTC 视频聊天

ios:使用任意 nsinputstream 播放视频

android - 是否可以开发在 Android 和 iOS 平台上运行的通用业务逻辑?

Android Webview 视频问题。视频正在 youtube iframe 中被裁剪。