Title: Why does scrolling a UIWebView *feel* so much different than scrolling any other UIScrollView?
Tags: ios;cocoa-touch;uiwebview;uiscrollview
Question: 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"?

Comment: @JackLawrence - The HTML is actually user-generated, pulled from the server periodically, and stored in core data. I could theoretically implement the view with native controls, but it's not as flexible as displaying the user-generated data directly.

Comment: What sort of HTML are you displaying? Maybe there's a way to accomplish everything using native controls.

Here is the accepted answer: 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;
```

Comment for this answer: @BrentRoyal-Gordon I just stumbled upon this question and i'm wondering: if `normal` scroll deceleration rate is `0.998000` and `fast` is `0.990000` which is lower than `normal`, then shouldn't the `webview` value of `0.989324` which is even lower than `fast` make the scroll even speedier instead of slower? That is, web views being more expensive to render, i would have expected a value larger than `0.998000` for the deceleration rate, not lower. Am i missing something?
Comment for this answer: This is fantastic! I hope it works for my project. Thank you.
Comment for this answer: It's worth noting that this is done because web views are much more expensive to render than most other views. Making the scrolling "stiffer" helps hide this by ensuring there's less new area to draw when the user scrolls. That's not to say you shouldn't change this if you know a particular web view can handle it, but keep in mind that it *is* being done for a reason and you should make sure it's not a problem for your use case.
Comment for this answer: Silky smooth. Just perfect. Thanks!
Comment for this answer: Deceleration is an ambiguous term. It makes better sense if you think of it as the magnitude of negative acceleration. Probably applied as v' = v(1-r).


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:02/07/13', 'FavoriteCount': 10.0, 'PostTypeId': 1, 'Tags': '<ios><cocoa-touch><uiwebview><uiscrollview>', 'Title': 'Why does scrolling a UIWebView *feel* so much different than scrolling any other UIScrollView?', 'ViewCount': 7680, 'id': 14763255, 'user_AboutMe': "<p>I don't really build things; I just build until things come into being.</p>\n", 'user_AccountId': 1568172.0, 'user_DisplayName': 'wxactly', 'user_Reputation': 2340.0, 'user_Views': 146.0, 'user_id': 1456495.0}}