tech savvy
tech savvy

Reputation: 1435

How to find if the scroll position in the webview for scrolling till the end or till the top?

How can I find if the webview has been scrolled till the top or till the last?

What checks do I need to keep on scroll offset for these two cases and which function/ delegate menthod, do I need to check it so that I know that the user has scrolled till the end or till the top?

Actually I have to change the frame of UIWebview and other views in my screen for this purpose.

Upvotes: 1

Views: 583

Answers (1)

arturgrigor
arturgrigor

Reputation: 9441

Take a look at the UIScrollViewDelegate.

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

Update

Here's an example:

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

Upvotes: 1

Related Questions