0
votes

I'm loading a local html template with some js code into webview. It works most of the time. But sometimes, the shouldStartLoadWithRequest delegate gets called once and won't get called at all later. By the way, I'm seeing this issue more consistently in iOS 9.1 and above.

Whenever this issue occurs, if I recreate the webview and load same content, then it works fine. So, I wanted to know why it doesn't work the first time (inconsistent) but works the second time.

I'm calling

[_webView setDelegate:nil]; 
//and 
[_webView stopLoading]; in dealloc method.

Would be helpful if anyone can suggest something.

1
@Avijit Adding "thanks" is the opposite of what an edit should do. You're actually encouraged to remove thanks from posts, see meta.stackexchange.com/questions/2950/…Benjamin W.

1 Answers

0
votes

I think somewhere your webView just loses its delegate. So it may just reset it with other one somewhere in code or just seed with nil. Looking to your posted code I can predict such situation - two instances has references to this webView. One instance should delete and it's calling dealloc method - webView delegate sets to nil, but other instance still using this same webView, but now it has delegate nil. As delegate is nil than webView won't send any message to him. It's only my prediction, still you'd should check if your delegate is nil or not and than begin new problem research. Good luck.