iPhone dev: Increase scroll speed in UIWebView?

后端 未结 5 1173
滥情空心
滥情空心 2021-02-09 04:41

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

5条回答
  •  梦毁少年i
    2021-02-09 05:09

    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.

提交回复
热议问题