atomikpanda
atomikpanda

Reputation: 1886

Disable Scrolling UIWebView

How can I disable scrolling in a UIWebView? I also would like to disable the "scrolling bounce".

Thanks in advance!

Upvotes: 3

Views: 7955

Answers (1)

user529758
user529758

Reputation:

On iOS 5.x, UIWebView has a backing scrollView property:

webView.scrollView.scrollEnabled = NO;
webView.scrollView.bounces = NO;

On iOS 4.x and earlier, UIWebView itself inherits from ScrollView:

webView.scrollEnabled = NO;
webView.bounces = NO;

If you want to check for being on iOS 4 or 5, you can test for UIWebView responding to the scrollView property getter:

if ([webView respondsToSelector:@selector(scrollView)]) {
    webView.scrollView.scrollEnabled = NO;
    webView.scrollView.bounces = NO;
} else {
    webView.scrollEnabled = NO;
    webView.bounces = NO;
}

Upvotes: 24

Related Questions