I have a Navigation controller that manages through a segue two web views. When someone clicks a specific link in the first view controller, the link is opened in the second view controller in another web view. Therefore the user clicks a link, a segue is performed to the next view and the new page is loaded.
I would like for the segue to wait until the webpage in the second view controller has loaded in the background before performing the segue.
I tried to do something like this (as the loadURL request in in the viewDidLoad function) but (as I expected) I get an error (fatal error: Can't unwrap Optional.None) as the webView has not yet loaded! Anyone knows how to prevent this?
//code
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
if(segue.identifier == "second"){
segue.destinationViewController.load()
segue.destinationViewController.viewDidLoad()
}
}