简体   繁体   中英

Disable Scrolling UIWebView

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

Thanks in advance!

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM