本文介绍了如何阻止UIWebView从“反弹"垂直滚动底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与此问题相同,但有一个区别.当我滚动到顶部刷新我的网站时,我只想停止跳到底部滚动的结尾.我该怎么办?

My question is the same as this question, but has one difference. When I scroll to top refresh my website, I want stop bouncing only to the end of the bottom scroll. How do I do this?

推荐答案

您可以尝试这样:

override func viewDidLoad() {
    super.viewDidLoad()

    webview.scrollView.delegate = self

}

func scrollViewDidScroll(scrollView: UIScrollView) {

    if (scrollView.contentOffset.y >= scrollView.contentSize.height - scrollView.frame.size.height) {
        scrollView.setContentOffset(CGPointMake(scrollView.contentOffset.x, scrollView.contentSize.height - scrollView.frame.size.height), animated: false)
    }   
}

设置您的Web视图的委托并设置Web视图的滚动视图的内容偏移量

Set the delegate of your webview and set the content offset of the webview's scrollview

引用来自: https://stackoverflow.com/a/14084747/4557505

这篇关于如何阻止UIWebView从“反弹"垂直滚动底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 16:29