Advertisement
thieumao

Load file PDF local to webview

May 12th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.61 KB | None | 0 0
  1. import UIKit
  2.  
  3. class ViewController: UIViewController {
  4.  
  5.     override func viewDidLoad() {
  6.         super.viewDidLoad()
  7.         // pdf file path
  8.         let urlString = NSBundle.mainBundle().URLForResource("crew", withExtension: "pdf")
  9.        
  10.         let urlRequest = NSURLRequest(URL: urlString!)
  11.         let webView = UIWebView(frame: self.view.bounds)
  12.         webView.loadRequest(urlRequest)
  13.        
  14.         self.view.addSubview(webView)
  15.     }
  16.  
  17.     override func didReceiveMemoryWarning() {
  18.         super.didReceiveMemoryWarning()
  19.         // Dispose of any resources that can be recreated.
  20.     }
  21.  
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement