Swift UIScrollViewDelegate 不触发 scrollViewDidScroll 事件

Swift UIScrollViewDelegate not triggers scrollViewDidScroll event

我的 UIViewController 中有两个 UIScrollViews 它们都有不同的属性,例如 pagingEnabledcontentSizecontentInset 我也需要它们滚动时分别表现,所以我创建了两个单独的自定义 类,如下所示。

class NavigationScrollView: UIScrollView{

}

class ContentScrollView: UIScrollView{

}

也代表

extension NavigationScrollView: UIScrollViewDelegate{
    // this method not triggers
    func scrollViewDidScroll(scrollView: UIScrollView) {

    }
}
extension ContentScrollView: UIScrollViewDelegate{
    // this method not triggers
    func scrollViewDidScroll(scrollView: UIScrollView) {

    }    
}

主要viewControllerviewDidLoad()我做

navigationScroller = NavigationScrollView(frame: CGRectMake(0.0, 0.0, frameWidth, 40.0))
contentScroller = ContentScrollView(frame: CGRectMake(0.0, 0.0, frameWidth, frameHeight))

你这样分配委托怎么样?

    class NavigationScrollView: UIScrollView{
        override func didMoveToSuperview() {
            super.didMoveToSuperview()
            self.delegate = self
        }
    }

    class ContentScrollView: UIScrollView{
        override func didMoveToSuperview() {
            super.didMoveToSuperview()
            self.delegate = self
        }
    }