UIScrollViewDelegate method only called when view is initialised

168 views Asked by At

I'm trying to set a scrollView method that will essentially disable the bounce at the bottom of the view. So, I've made my view controller conform to UIScrollViewDelegate:

 class MainViewController: I6ViewController, UITextFieldDelegate, UIScrollViewDelegate 

I've set the scrollView's delegate to self in my init:

scrollView.delegate = self

And I'm trying to trigger this method;

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    if scrollView.contentOffset.y > scrollView.contentSize.height - scrollView.bounds.height {
        scrollView.contentOffset.y = scrollView.contentSize.height - scrollView.bounds.height
    }
}

However, whilst the method is called when the view is initialised. it is never called subsequently when scrolling. What am I doing wrong here?

0

There are 0 answers