我想在收藏視圖單元格中長時間按下時共享mp3文件。我寫了下面的代碼,但它什麼也沒有返回。我是指當我給自己發送電子郵件時。它不包括mp3文件,而且我也看不到whatsapp部分。在swift 3中分享mp3文件
let r = NSURL(fileURLWithPath: temp_url!)
//var activityItems: [Any] = [temp_url!]
let activityViewController = UIActivityViewController(activityItems: [r], applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash
// exclude some activity types from the list (optional)
let excludeActivities = [UIActivityType.airDrop, UIActivityType.print, UIActivityType.assignToContact, UIActivityType.saveToCameraRoll, UIActivityType.addToReadingList, UIActivityType.postToFlickr, UIActivityType.postToVimeo, UIActivityType.postToFacebook, UIActivityType.message, UIActivityType.postToWeibo]
activityViewController.excludedActivityTypes = excludeActivities
// present the view controller
self.present(activityViewController, animated: true, completion: nil)
// exclude some activity types from the list (optional)
activityViewController.excludedActivityTypes = [ UIActivityType.airDrop, UIActivityType.postToFacebook ]
// present the view controller
self.present(activityViewController, animated: true, completion: nil)
「我發現這個帖子斯威夫特:通過whatsapp分享mp3文件,但它也不適用於我。」這是非常無益的。具體而且詳細地說,它不能爲你工作嗎? –
對不起,我更新了這篇文章。 –
你應該使用URL而不是NSURL在Swift3 –