I'm trying to hook up a scroll view using Interface Builder, and the UIScrollViewDelegate.scrollViewDidScroll
method isn't getting invoked on scroll.
In IB, I have a view controller that uses my PagedScrollViewController
as a custom class. In that class, I have:
class PagedScrollViewController: UIViewController, UIScrollViewDelegate {
func scrollViewDidScroll(scrollView: UIScrollView!) {
println("scrollViewDidScroll")
}
}
Unfortunately, that println
is never getting invoked. I know that PagedScrollViewController
is being connected correctly because if I add a viewDidLoad
method, that gets invoked. Is there something extra I need to do to attach the delegate other than setting the custom class?
Turns out I needed to attach the scroll view's delegate to the the controller. Here's what worked for me:
class PagedScrollViewController: UIViewController, UIScrollViewDelegate {
@IBOutlet var scrollView: UIScrollView!
override func viewDidLoad() {
super.viewDidLoad()
scrollView.delegate = self
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With