Search code examples
iphoneuiwebview

iPhone - Is it possible to hide native scrollbar in UIWebView?


I would like to hide the native scrollbar / scroller that appears when you are scrolling a UIWebView, but still keep the scrolling functionality intact. Is this possible?

Thanks in advance,

William


Solution

  • It seems this question needs an updated answer:

    You can directly access the scroll view associated with the web view. (read-only) in iOS 5.0 an above. I don't think developers should be supporting anything prior to iOS 5.0 unless in exceptional circumstances.

    From the Apple developer docs.

    @property(nonatomic, readonly, retain) UIScrollView *scrollView
    Discussion
    Your application can access the scroll view if it wants to customize the scrolling behavior of the web view.
    
    Availability
    Available in iOS 5.0 and later.
    Declared In
    UIWebView.h
    

    Now you can directly write something like this:

    webView.scrollView.showsHorizontalScrollIndicator = NO;
    webView.scrollView.showsVerticalScrollIndicator = NO;
    

    No need to go to the subviews of the webView.