UIScrollViewDelegate. scrollViewDidScroll does not receive a call (Swift / Interface Builder / Xcode 6)

I am trying to connect a scroll view using Interface Builder, and the method UIScrollViewDelegate.scrollViewDidScrolldoes not start when scrolling.

In IB, I have a view controller that uses mine PagedScrollViewControlleras a custom class. In this class, I have:

class PagedScrollViewController: UIViewController, UIScrollViewDelegate {
    func scrollViewDidScroll(scrollView: UIScrollView!) {
        println("scrollViewDidScroll")
    }
}

Unfortunately, this one printlnnever starts. I know that it PagedScrollViewControllerconnects correctly, because if I add a method viewDidLoadthat will be called. Is there anything extra I need to do to join the delegate other than setting up a custom class?

+4
source share
1 answer

Turns out I needed to attach a scroll view delegate to the controller. Here is what worked for me:

class PagedScrollViewController: UIViewController, UIScrollViewDelegate {
    @IBOutlet var scrollView: UIScrollView!

    override func viewDidLoad() {
        super.viewDidLoad()
        scrollView.delegate = self
}
+7
source

Source: https://habr.com/ru/post/1568063/


All Articles