UIActivityViewController: 純文字、圖片分享
UIDocumentInteractionController:各種檔案分享
var docController = UIDocumentInteractionController()
@IBAction func share(_ sender: AnyObject) {
/*
/***************彈出分享Alert視窗(文字、圖片檔)********************/
let activityViewController = UIActivityViewController(activityItems: [audioFile], applicationActivities: nil)
self.present(activityViewController, animated: true, completion: nil)
/***************彈出分享Alert視窗********************/
*/
/***************彈出分享Alert視窗(各種檔案)********************/
//let path = Bundle.main.path(forResource: "Transfomer", ofType: "mp3")
//docController = UIDocumentInteractionController(url: URL(fileURLWithPath: path!))
docController = UIDocumentInteractionController(url: (myPlayer1?.url)!)//需宣告為全域變數 var docController = UIDocumentInteractionController()
docController.presentOptionsMenu(from: sender.frame, in:self.view, animated:true)
//docController.presentOpenInMenu(from: sender.frame, in: self.view, animated: true)
/***************彈出分享Alert視窗********************/
}
留言
張貼留言