Created
June 2, 2019 16:15
-
-
Save shawnbierman/4eccf2b4c087df9a0637a48e85c51206 to your computer and use it in GitHub Desktop.
webView fixes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
} | |
*/ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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