0

I have a UIWebview that loads some local content. I have hooked up two buttons that fires the webView's goBack and goForward methods respectively.

When not scrolling the page, tapping either of the buttons instantly navigates the page backwards or forwards. But if i tap one of the buttons while the current page is scrolling, the next page will not start to load until the current page has stopped scrolling.

I tried putting a log in

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest...

The log shows that it isn't being fired until when the page is done scrolling.

The delay is quite small when using UIWebViews default scrolling behaviour. But I have changed that to get a more native feel by doing:

webView.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;

When scrolling long pages, the problem becomes apparent as it can take several seconds before the scrolling is done and the next page loads.

Has anyone else experienced this and found a solution?

reekris
  • 508
  • 7
  • 12

1 Answers1

1

Because event tracking in UIScrollview blocks the main thread.

You can try to force scrollView end scrolling(or decelerating) before another web action.

Ref: How can I programmatically force-stop scrolling in a UIScrollView?

Community
  • 1
  • 1
Chris
  • 428
  • 2
  • 10
  • Thanks, it works great! I solved it by adding the killScroll method from the linked solution to my webView subclass and I'm calling it on ```goBack```, ```goForward```and ```loadRequest```. It stops scrolling and loads the next page instantly. – reekris Aug 28 '13 at 08:41