我想在我的应用中分享视频,例如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 })
}