Ios – Open PDF file using swift


How can I add a PDF file for an app , where you click on a button to view the file & when you're done you get back to screen you were at?

Best Answer

If you simply want to view a PDF file you can load it into a UIWebView.

let url : NSURL! = NSURL(string: "")
webView.loadRequest(NSURLRequest(URL: url))

Swift 4.1 :

let url: URL! = URL(string: "")
webView.loadRequest(URLRequest(url: url))

If you'd like to achieve more, a good framework is PSPDFKit.