How to disable scrolling entirely in a WKWebView?

前端 未结 10 1713
再見小時候
再見小時候 2020-12-28 14:07

I know this looks like a simple question one can simply say:

webview.scrollView.scrollEnabled = NO;
webview.scrollView.panGestureRecognizer.enabled = NO;
web         


        
10条回答
  •  佛祖请我去吃肉
    2020-12-28 14:46

    I found that I had to make my view controller a UIScrollViewDelegate then add this function to prevent scrolling.

    func scrollViewDidScroll(_ scrollView: UIScrollView) {
       scrollView.setContentOffset(CGPoint(x: 0, y: 0), animated: false)
    }
    

提交回复
热议问题