Question

I have a UIWebView in my view controller and have set its delegate to the view controller via code (i.e. not through IB). I have also setup the appropriate delegate methods: shouldStartLoadWithRequest, webViewDidStartLoad, webViewDidFinishLoad and didFailLoadWithError.

In my view controller's viewDidLoad method I load an appropriate URL with this code:

[self.webView loadRequest:reqURL];

95% of the time everything works great and the page loads in the UIWebView object and displays as expected. Occasionally, however, the page doesn't load.

After stepping through my code I realized that on the times that it doesn't work the shouldStartLoadWithRequest delegate method fires, but webViewDidStartLoad doesn't.

Does anyone have any idea what's going on here? I couldn't find anything on Stack Overflow that specifically addressed this unique issue I'm having and am slowly reaching my breaking point. Thanks in advance!

Was it helpful?

Solution

You should make sure that your shouldStartLoadWithRequest implementation returns YES for all conditions at which you need your webView to load.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top