views:

370

answers:

2

I have an app in which I render local HTML files in a UIWebView. The files, however, are sometimes large, and getting to where you want takes a long time with the default scroll speed. Is there any way to boost up the vertical scroll speed of a UIWebView?

A: 

Search for a subview of UIWebView that responds to -setScrollDecelerationFactor: (it's UIScroller - a private class that's the only subview of UIScrollView). You'll find that it takes the same deceleration factors defined for the public UIScrollView class:

- (void)webViewDidFinishLoad:(UIWebView *)aView {
    id decelerator = [aView viewWithSelector:@selector(setScrollDecelerationFactor:)];
    [decelerator setScrollDecelerationFactor:UIScrollViewDecelerationRateNormal];
}

Note that the method I'm using viewWithSelector: is a method I defined in a category of UIView. Presumably, if UIWebView changes in future, my search will return nil and this method will become a no-op.

MrO
A: 

Have considered adding # tags into your html on significant boundaries?

You could actually use native UI to implement bookmarks or a ToC for easier navigation, or simply embed links to the appropriate targets right in your html.

If you 'speed up scrolling' your app is at risk of rejection for being non-standard, since it may confuse users who are used to webviews scrolling with a standard 'feel'.

Jonathan Watmough