[新SWIFT]我測試這個功能導出一些簡單的文件試圖導出到CSV,但我如何從委託實現?
@IBAction func exportFile(delegate: UIDocumentInteractionControllerDelegate) {
print("export csv")
let fileName = tmpDir.stringByAppendingPathComponent("myFile.csv")
let url: NSURL! = NSURL(fileURLWithPath: fileName)
if url != nil {
let docController = UIDocumentInteractionController(URL: url)
docController.UTI = "public.comma-separated-values-text"
docController.delegate = delegate
docController.presentPreviewAnimated(true)
}
}
// Return the view controller from which the UIDocumentInteractionController will present itself.
func documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController)-> UIViewController {
return self
}
但是,當我點擊導出按鈕我得到
UIDocumentInteractionController delegate must implement documentInteractionControllerViewControllerForPreview: to allow preview
我想
消息class ViewController:UIViewController,UIDocumentInteractionControllerDelegate {
足夠了嗎?
我試圖 Self.documentInteractionControllerViewForPreview(docController)
[編輯] 原來我犯了如下錯誤 docController.delegate =自//代表
嗯仍然得到消息,我不使用任何數據源。關於這個問題的任何文章? – alex