IPhone - UIWebView: User Scrolling Detection of Bottom of Page

So, I have a UIView with a UIWebView inside, serving a local HTML file (document preview). I also have Accept and Reject UIButtons. I need these buttons to appear only after the user scrolls to the bottom of the web page. Is there a way to capture a scroll event at the bottom of a UIWebView?

I have not seen any good answers for this, can anyone help?

Thanks in advance.

+3
source share
4 answers

UIWebView UIScrollViewDelegate. , UIWebView (, ScrollDetectWebView) UIScrollViewDelegate.

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [super scrollViewDidScroll: scrollView];

    // Whatever scroll detection you need to do
}
+5

?

?

0

JavaScript allows you to handle a scroll event and send an Objective-c message.

0
source
- (void)viewDidLoad {
    [super viewDidLoad];

     self.webView.scrollView.delegate = self;
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {

    CGSize fittingSize = [self.webView sizeThatFits:CGSizeZero];

    CGFloat height1 = scrollView.bounds.origin.y + self.webView.bounds.size.height;

    CGFloat height2 = fittingSize.height;

    int delta = fabs(height1 - height2);

    if (delta < 30) {

       NSLog(@"HELLO!!! You reached the page end!");
    }
    }
0
source

Source: https://habr.com/ru/post/1771358/


All Articles