考虑在Swift 3中的filePath如何显示pdf文件以及在哪里显示pdf文件? [英] how to display and where to display a pdf file by considering filePath in swift 3?

查看:133
本文介绍了考虑在Swift 3中的filePath如何显示pdf文件以及在哪里显示pdf文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS开发的新手.在我的项目中,我在tableview上显示一个exerciseFilePath. 响应如下.

I am new to iOS development. In my project i am displaying a exerciseFilePath on tableview. the response is given below.

    "exerciseId" : 1,
    "exerciseName" : "Fitness Exercise",
    "exerciseFilePath" : "\/p\/pdf\/exercise_pdf\/fitness_exercise.pdf"

我需要在didSelectRowAtIndexpath的另一个视图中显示pdf. 我不知道如何显示pdf以及显示该pdf需要遵循的步骤. 希望你能理解我的问题.请帮我怎么做.

i need to display the pdf in another view on didSelectRowAtIndexpath. i Dont know how to display the pdf and what are steps to be followed to display that pdf. I hope you understand my problem. please help me how I can do this.

推荐答案

为什么不使用 QLPreviewController UIDocumentInteractionController ?

现在,您可以使用webView来做到这一点:

Now in your case you can do it by using webView:

let req = NSURLRequest(url: pdf) //pdf is your pdf path
let webView = UIWebView(frame: CGRect(x:0,y:0,width:self.view.frame.size.width,height: self.view.frame.size.height-40)) //Adjust view area here
webView.loadRequest(req as URLRequest)
self.view.addSubview(webView)


一些教程:

QLPreviewController示例

UIDocumentInteractionController示例

这篇关于考虑在Swift 3中的filePath如何显示pdf文件以及在哪里显示pdf文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆