11

我正在编写一个具有本地保存视频 (.mov) 的 iOS 应用程序。我正在尝试通过 UIActivityViewController 附加视频。它非常适合电子邮件。视频已成功附加并发送。保存到相机胶卷时也可以使用。
附加到消息时它不起作用。仅显示文本。Twitter 和 Facebook 也没有出现。当我删除视频附件时,Twitter 和 Facebook 终于开始显示了。我不太关心消息,但谁能告诉我为什么 Facebook 和 Twitter 没有出现?

这是我的代码:

- (IBAction) shareVideo {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *URL = [documentsDirectory stringByAppendingPathComponent:demoName];

    NSString* someText = demoName;
    NSURL *urlToShare = [NSURL fileURLWithPath:URL isDirectory:NO];
    NSArray* dataToShare = @[someText, urlToShare];

    UIActivityViewController* activityViewController =
    [[UIActivityViewController alloc] initWithActivityItems:dataToShare
                                      applicationActivities:nil];
    activityViewController.excludedActivityTypes = @[UIActivityTypePrint,UIActivityTypeCopyToPasteboard,UIActivityTypeAssignToContact];

    activityViewController.completionHandler = ^(NSString *activityType, BOOL completed) {
        //if (completed) {
        [self dismissViewControllerAnimated:YES completion:nil];
        //}
    };

    [self presentViewController:activityViewController animated:YES completion:nil];
}
4

3 回答 3

8

其他答案已过时。这有效:

    @IBAction func didTapShare(sender: AnyObject) {
    let videoURL = NSURL(fileURLWithPath:localVideoPath)
    let activityItems = [videoURL, "Check this out!" ]
    let activityController = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)

    activityController.popoverPresentationController?.sourceView = self.view
    activityController.popoverPresentationController?.sourceRect = self.view.frame

    self.presentViewController(activityController, animated: true, completion: nil)
}
于 2016-05-22T06:19:37.837 回答
4

在 iOS 6 或更低版本中,您无法在 Facebook、Twitter 或短信上分享视频。它仅在 iOS7 中可用。

另外,请查看https://stackoverflow.com/a/20211603/2074320了解您的信息。

于 2013-11-26T09:24:17.560 回答
1

它们是隐藏的,因为您无法在 fb twitter 或短信中显示 mov

于 2012-12-23T09:11:59.727 回答