如何分享iPhone默认分享视频

时间:2016-04-20 12:22:10

标签: ios swift swift2

我想在我的应用中分享视频,例如iPhone视频共享的默认分享。 我编写了代码,但它不像iPhone默认共享

here are difference between my share function and iPhone default share

 func shareVideo() {

    let paths = NSSearchPathForDirectoriesInDomains(
        NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)
    let documentsDirectory: AnyObject = paths[0]
    let dataPath = documentsDirectory.stringByAppendingPathComponent("saveFileName")

    let URL: String = documentsDirectory.stringByAppendingPathComponent(dataPath)
    let someText: String = "A nice song"
    let urlToShare: NSURL = NSURL.fileURLWithPath(URL, isDirectory: false)
    let dataToShare: [AnyObject] = [someText, urlToShare]
    let activityViewController: UIActivityViewController = UIActivityViewController(activityItems: dataToShare, applicationActivities: nil)
    activityViewController.excludedActivityTypes = [UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact]

    self.presentViewController(activityViewController, animated: true, completion: { _ in })
}

0 个答案:

没有答案