1

我有一个 iOS 应用程序,它生成一个 CSV 文件并将其保存到设备的工作文档目录中。现在,当用户按下按钮时,会显示 UIActivityViewController 共享表,它允许您打开将数据发送到其他应用程序。

我的问题是如何将此 CSV 文件传递​​到共享表。我知道如何使它与文本和图像一起使用,但不完全确定如何使它与 CSV 文件一起使用。最终结果是我希望此文件在从共享表中选择的任何电子邮件客户端中显示为附件。

4

1 回答 1

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
}
于 2015-09-07T04:38:38.713 回答