我正在尝试与Vimeo和Facebook分享视频。我可以从库中做到这一点,但是当我尝试在代码中创建它时,它已经失败了,我已经尝试了这个
func showSheet() {
let bundle = NSBundle.mainBundle()
let videoURL:NSURL = NSURL.fileURLWithPath(self.outputUrl!)!
//let asset:AVAsset = AVAsset.assetWithURL(videoURL) as AVAsset
let asset:ALAsset = ALAsset.setVideoAtPath(videoURL)
//NSString* path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/image.mov"];
//NSURL *videoURL = [NSURL fileURLWithPath:myFilePath];
let objectsToShare = [textToShare, asset]
//let objectsToShare = [textToShare, videoURL]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.excludedActivityTypes = [UIActivityTypeAddToReadingList]
self.presentViewController(activityVC, animated: true, completion: nil)
}
从注释行中可以看出,我尝试传递NSURL,AVAsset和ALAsset,唯一有效的是NSURL。我可以通过iMessage发送它,但它不适用于Facebook。此外,Vimeo和YouTube从未出现在列表中,即使它们在我从照片库触发工作表时出现。我究竟做错了什么?在this page底部的数据网格之后,我应该能够传递资产。