Detect when I scroll my UIWebView at top of the page

后端 未结 3 2029
萌比男神i
萌比男神i 2021-01-15 11:33

I would like to add an URL/google bar on top of my webview, and access it by scrolling up my web page exactly as Safari do. To do this, I would detect when the user is scrol

3条回答
  •  一生所求
    2021-01-15 12:16

    I was also digging for the same and found a solution. I coded the following method to detect the scrolling coordinates. See below:

    -(void)userDidScrollWebView:(id)scrollPoint{
        // NSLog(@"scrolled:::");
    
        NSString *x1 = [webView stringByEvaluatingJavaScriptFromString: @"scrollX"];
    
    
        NSString *y1 = [webView stringByEvaluatingJavaScriptFromString: @"scrollY"];
    
    
        NSLog(@"scroll x=%@ y=%@", x1,y1);      
    
        if ([y1 isEqualToString: @"0"]) {
            NSLog(@"RELAOD ME");
        }   
    }
    

    Hope it helps you.

提交回复
热议问题