【问题标题】:How to find if the scroll position in the webview for scrolling till the end or till the top?如何查找 webview 中的滚动位置是滚动到最后还是滚动到顶部?
【发布时间】:2014-01-22 22:21:49
【问题描述】:

如何查看 webview 是滚动到顶部还是滚动到最后?

对于这两种情况,我需要进行哪些检查来保持滚动偏移以及哪个函数/委托方法,我是否需要检查它以便我知道用户滚动到最后还是到顶部?

实际上我必须为此更改屏幕中 UIWebview 和其他视图的框架。

【问题讨论】:

    标签: ios objective-c uiwebview uiscrollview uiwebviewdelegate


    【解决方案1】:

    看看UIScrollViewDelegate

    https://developer.apple.com/library/ios/documentation/uikit/reference/uiscrollviewdelegate_protocol/reference/uiscrollviewdelegate.html

    更新

    这是一个例子:

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
        float scrollViewHeight = scrollView.frame.size.height;
        float scrollContentSizeHeight = scrollView.contentSize.height;
        float scrollOffset = scrollView.contentOffset.y;
    
        if (scrollOffset == 0)
        {
            // then we are at the top
        }
        else if (scrollOffset + scrollViewHeight == scrollContentSizeHeight)
        {
            // then we are at the end
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2011-11-11
      • 2018-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多