我有一个iOS应用程序,它生成一个CSV文件并将其保存到设备的工作文档目录中。现在,当用户按下按钮时,会显示UIActivityViewController共享表,允许您打开向其他应用程序发送数据。
我的问题是如何将此CSV文件传递到共享表。我知道如何使用文本和图像进行此工作,但不确定如何使用CSV文件。最终结果是我希望此文件显示为从共享表中选择的任何电子邮件客户端中的附件。
答案 0 :(得分:0)
这是我用来打开文档的代码(word,pdf等)。应该适合你...
@IBAction func openDocument(sender: AnyObject)
{
let interactionController = UIDocumentInteractionController(URL: documentURL)
// (build your document's URL from its path in the Documents directory)
interactionController.delegate = self
// First, attempt to show the "Open with... (app)" menu. Will fail and
// do nothing if no app is present that can open the specified document
// type.
let result = interactionController.presentOpenInMenuFromRect(
self.view.frame,
inView: self.view,
animated: true
)
if result == false {
// Fall back to "options" view:
interactionController.presentOptionsMenuFromRect(
self.view.frame,
inView: self.view,
animated: true)
}
// DONE
}