【发布时间】:2018-03-14 05:40:40
【问题描述】:
我正在尝试在下载后打开一个.pdf 文件,该文件是使用 Alamofire 下载的。但我只看到使用“webview”。因此,应用程序会消耗大量内存并且不可行。
我想要的是用本机设备应用程序打开它。有什么建议?谢谢。
编辑:这是我的下载文件代码:
var localPath: NSURL?
Alamofire.download(.GET, url, destination: { (temporaryURL, response) in
let directoryURL = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0]
let pathComponent = response.suggestedFilename
localPath = directoryURL.URLByAppendingPathComponent(pathComponent!)
return localPath!
})
.response { (request, response, _, error) in
if error != nil
{
// got an error in getting the data, need to handle it
print("Error: \(error!)")
}
//print(response)
print("Download file en:\(localPath!)")
self.view.hideToastActivity()
//self.actioncall()
}
}
我需要从本地路径打开文件...
【问题讨论】:
-
听说过 UIDocumentInteractionController 吗??如果没有尝试阅读它。我相信这就是你所需要的 :) 快乐编码 :)
-
你应该展示你已经做了什么。
-
更新操作。我会读@SandeepBhandari