Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does scrolling a UIWebView *feel* so much different than scrolling any other UIScrollView?

I'm building an app that loads in a small amount of simple HTML (locally) into a single full-screen UIWebView. I'm noticing that scrolling this web view feels significantly different than scrolling any other UIScrollView. This does not appear to be a performance or a responsiveness issue, per se... It's just a matter of how the momentum plays out as you drag and flick the web view up and down. It just doesn't feel very "native" (for lack of a better word). It's like scrolling through molasses or pudding... kinda "sticky" and not as "slick" as you would like it to feel.

Does anyone know what causes this? Is there any way to fix it, or at the very least make scrolling a UIWebView feel more "native"?

like image 804
wxactly Avatar asked Feb 07 '13 23:02

wxactly


1 Answers

I have the same perception. It must have to do with the webView's scrollView deceleration rate. Just ran this test, and 1) it confirms our suspicion and 2) suggests a fix.

I added a scrollView and a webView to my UI then logged the following:

NSLog(@"my scroll view's decel rate is %f", self.scrollView.decelerationRate); NSLog(@"my web view's decel rate is %f", self.webView.scrollView.decelerationRate); NSLog(@"normal is %f, fast is %f", UIScrollViewDecelerationRateNormal, UIScrollViewDecelerationRateFast); 

The output confirms the guess about webView being more frictional:

my scroll view's decel rate is 0.998000 my web view's decel rate is 0.989324 normal is 0.998000, fast is 0.990000 

And suggests a fix:

self.webView.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal; 
like image 139
danh Avatar answered Sep 16 '22 14:09

danh