第一步:先实现代理UIScrollViewDelegate
-
(UIWebView *)webView
{
if (!_webView)
{
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 20, YFkScreenWidth, YFkScreenHeight-20 )];
webView.delegate = self;
webView.scrollView.delegate = self;
[self.view addSubview:webView];
_webView = webView;}
return _webView;
}
第二步:实现UIScrollView滑动事件监听
pragma mark - scrollView协议
-
(void)scrollViewDidScroll:(UIScrollView *)scrollView{
//禁止webView底部回弹效果
if (scrollView.contentSize.height - scrollView.contentOffset.y <= YFkScreenHeight-20) {
self.webView.scrollView.bounces=NO;
}else{
self.webView.scrollView.bounces=YES;
}
}