I'm running into a bizarre problem - I cannot load a UIWebView in the background of a separate viewcontroller. Specifically, I have a UITableViewCell with a button to load a UIWebView in the viewcontroller behind it. However, I keep getting the error "found nil while unwrapping an Optional value"...
Here is my code:
func loadWebView(URLString:String) {
print("the urlstring is \(URLString)")
let theRequestURL = NSURL (string: URLString)
let theRequest = NSURLRequest (URL: theRequestURL!)
fullScreenWebView.loadRequest(theRequest)
}
The print statement yields the correct URL, so the issue isn't that the URL string isn't being passed.
Furthermore, if I load the UIWebView from the viewcontroller it's defined in, it works perfectly. I'm guessing the issue has to do with not being the correct viewcontroller when loadWebView() is called... I read Unable to display URL in WebView from another view controller, which was somewhat helpful.
What am I doing wrong?
UIViewControllerwithUIWebView. Have to initializedfullScreenWebView? - UditSloadRequestin controller B. So how are you passing the reference of the view controller to Controller B? - UditS