【发布时间】:2016-01-29 02:48:32
【问题描述】:
它成功重定向到Whatsapp应用程序。没有预览框架,点击发送时弹出错误消息“无法发送此视频。请选择其他视频。
这是我的代码。
- (void)shareVideo {
NSLog(@"[WhatsAppShare] sharing video");
//NSString *nativePath = [[NSString alloc] initWithCString:path encoding:NSASCIIStringEncoding];
NSString *nativePath=[[NSBundle mainBundle] pathForResource:@"video" ofType:@"mp4"];
// Save video to path in documents directory
NSString *savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wam"];
if([[NSFileManager defaultManager] fileExistsAtPath:savePath]){
if([[NSFileManager defaultManager] removeItemAtPath:savePath error:nil]){
[self shareVideoAtNativePath:nativePath SavePath:savePath];
}
} else {
[self shareVideoAtNativePath:nativePath SavePath:savePath];
}}
- (void)shareVideoAtNativePath:(NSString*)nativePath SavePath:(NSString*)savePath{
NSError*error;
BOOL isSuccess=[[NSFileManager defaultManager] copyItemAtPath:nativePath toPath:savePath error:&error];
if(isSuccess){
// Create interaction controller
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
self.documentInteractionController.UTI = @"net.whatsapp.movie";
self.documentInteractionController.delegate = self;
[self.documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 1, 1)
inView:[self view]
animated:YES];
} else{
NSLog(@"error %@", error);
}
}
【问题讨论】:
-
虽然阿里的回答是正确的(
.wam分享在最新版本的 WhatsApp 中被破坏)你可以将视频分享为.m4v,它会正常工作。