Skip to content

Instantly share code, notes, and snippets.

@shawnbierman
Created June 2, 2019 16:15
Show Gist options
  • Save shawnbierman/4eccf2b4c087df9a0637a48e85c51206 to your computer and use it in GitHub Desktop.
Save shawnbierman/4eccf2b4c087df9a0637a48e85c51206 to your computer and use it in GitHub Desktop.
webView fixes
class NewViewController: UIViewController {
@IBOutlet var webView: WKWebView!
var fileToLoad: URL?
override func loadView() {
webView = WKWebView()
self.view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
guard let url = fileToLoad else { return }
let request = URLRequest(url: url)
webView.load(request)
// Do any additional setup after loading the view.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
func OpenFile(fileToLoad: String) {
let SecondScreen = self.storyboard?.instantiateViewController(withIdentifier: "NewViewController") as! NewViewController
let dirPaths = FM.urls(for: .documentDirectory, in: .userDomainMask)
let docsDir = dirPaths[0].appendingPathComponent(fileToLoad)
SecondScreen.fileToLoad = docsDir
self.present(SecondScreen, animated: true, completion: nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment