UIDocumentInteractionController不起作用

时间:2016-10-10 12:41:06

标签: ios swift uidocumentinteraction

使用UIDocumentInteractionController共享文件并将openIn选项添加到我的应用程序,但是当我按下发送电子邮件时我收到了一封空电子邮件,我从consol收到错误尝试在取消分配时加载视图控制器的视图是不允许的,可能导致未定义的行为()

如果我尝试保存图像"保存图像"我收到此错误无法获取(null)的文件大小:(null)

这是我的代码

    var documentInteractionController:UIDocumentInteractionController?
    open func ShareButtonPressed(_ sender:UIButton){
    let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] + "/downloads"
    let name = String(format: "%@_%@", objDownloads[currentPageIndex].modificationDate!, objDownloads[currentPageIndex].fileName!)
    let url:URL = URL(fileURLWithPath: documentsPath.stringByAppendingPathComponent(name))
    let documentInteractionController = UIDocumentInteractionController(url:url)
    documentInteractionController.uti = objDownloads[currentPageIndex].fileName
    documentInteractionController.presentOptionsMenu(from: sender.frame, in: self.view, animated: true)
    documentInteractionController.delegate = self
}

这是我的按钮代码

    let shareBtn = UIButton()
    let shareIcon = UIImage(named: "share_icon")


    shareBtn.addTarget(self, action: #selector(SKPhotoBrowser.ShareButtonPressed(_:)), for: UIControlEvents.touchUpInside)

0 个答案:

没有答案