I have a simple view controller with UIWebView and few basic buttons (back, forward and refresh), when I test the controller with "simple" sites (a good example can be this site) all is working good, all 4 delegates from UIWebViewDelegate triggers.
The problem start when I try to load twitter or other kind of sites with the same implementation. The first loading trigger all the delegates but after that all goes blank, as a result canGoBack and canGoForward return 0 for each request. The odd part is that in the first build with a fresh simulator goBack and canGoBack will work in a fresh app build.
Let's take a look at this code example (I removed all the unnecessary code): http://pastebin.com/8jNYptyj
Let's change the twitter URL (in viewDidLoad) to another site to show that the basic functionality works, for example - https://developer.apple.com/
When I build and run this demo I get the following log -
2014-03-14 15:07:50.797 My Sandbox[813:60b] shouldStartLoadWithRequest.
2014-03-14 15:07:50.799 My Sandbox[813:60b] webViewDidStartLoad.
2014-03-14 15:07:53.874 My Sandbox[813:60b] webViewDidFinishLoad - https://developer.apple.com/
Then let's click on 'Learn more' link, now we will get this log -
2014-03-14 15:08:56.109 My Sandbox[813:60b] shouldStartLoadWithRequest.
2014-03-14 15:08:56.111 My Sandbox[813:60b] webViewDidStartLoad.
2014-03-14 15:08:58.085 My Sandbox[813:60b] webViewDidFinishLoad - https://developer.apple.com/ios7/
And finally let's hit the back button, now we will get this log -
2014-03-14 15:10:00.402 My Sandbox[813:60b] shouldStartLoadWithRequest.
2014-03-14 15:10:00.403 My Sandbox[813:60b] webViewDidStartLoad.
2014-03-14 15:10:00.732 My Sandbox[813:60b] webViewDidFinishLoad - https://developer.apple.com/
This example works great and canGoBack return the correct value for each step (not in log).
Now let's run the same thing with the twitter example, before that I'll remove the app from the simulator and build fresh app.
When I build and run this demo I get the following log -
2014-03-14 15:13:06.993 My Sandbox[848:60b] shouldStartLoadWithRequest.
2014-03-14 15:13:06.995 My Sandbox[848:60b] webViewDidStartLoad.
2014-03-14 15:13:09.176 My Sandbox[848:60b] webViewDidFinishLoad - https://mobile.twitter.com/appstore
Then let's click on the first tweet, now we will get this log -
And finally let's hit the back button, now we will get this log -
As you can see none of the triggers fired this time, the odd thing was that the first time with fresh app build goBack was working and canGoBack return 1.
NOTE: If you will build and run the same test with twitter again goBack won't work this time.
So yea... I'm really confused about this problem but it seems like a caching issue with this kind of sites.
Any ideas?