我的UIScrollViews
中有两个UIViewController
,它们都有不同的属性,例如pagingEnabled
,contentSize
& contentInset
我还需要它们在滚动时单独行动,所以我创建了两个单独的自定义类,如下所示。
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) {
}
}
在主viewController
viewDidLoad()
我做
navigationScroller = NavigationScrollView(frame: CGRectMake(0.0, 0.0, frameWidth, 40.0))
contentScroller = ContentScrollView(frame: CGRectMake(0.0, 0.0, frameWidth, frameHeight))
答案 0 :(得分:2)
你怎么用这种方式分配代表?
class NavigationScrollView: UIScrollView{
override func didMoveToSuperview() {
super.didMoveToSuperview()
self.delegate = self
}
}
class ContentScrollView: UIScrollView{
override func didMoveToSuperview() {
super.didMoveToSuperview()
self.delegate = self
}
}