2

I have a collectionView and in each cell I have a WKWebView loading html from a local file. I want to scroll down to a specific offset from code.

I have tried using:

self.webView.scrollView.contentOffset.y = offSet

and

self.webView.scrollView.setContentOffset(CGPoint(x: 0, y: offSet), animated: false)

with and without layoutIfNeeded()

but with no success.

The func scrollViewDidScroll(_ scrollView: UIScrollView) {} Does get called and the contentOffset.y does increase, but the scroll view does not move at all.

Rafael
  • 21
  • 1
  • Maybe answer in this topic will help you https://stackoverflow.com/questions/51659208/how-to-programmatically-scroll-ios-wkwebview-swift-4. Answer https://stackoverflow.com/a/53542236/9048325 – Vladyslav Shmatok Oct 08 '19 at 19:03
  • That's basically what I have tried. I might have an issue somewhere because my scrollview does not move no matter what value I try to offSet it by, not sure why. – Rafael Oct 08 '19 at 19:16

0 Answers0