【发布时间】:2017-08-03 11:20:01
【问题描述】:
我想在外部视图滚动时滚动我的收藏视图... 我找到了这个答案:How to make a collectionview respond to pan gestures outside of it's own view,但它对我不起作用。
viewController 中的代码
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
pager.touchesBegan(touches, with: event)
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesMoved(touches, with: event)
pager.touchesMoved(touches, with: event)
}
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesCancelled(touches, with: event)
pager.touchesCancelled(touches, with: event)
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)
pager.touchesEnded(touches, with: event)
}
override func viewDidLoad() {
super.viewDidLoad()
pager = Carousel(withFrame: self.view.bounds, andInsets: 5)
pager.dataSource = self
pager.translatesAutoresizingMaskIntoConstraints = false
pager.register(MyCollectionView.self, forCellWithReuseIdentifier: "Cell")
self.swipeView.addSubview(pager)
pager.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 1).isActive = true
pager.heightAnchor.constraint(equalToConstant: 300).isActive = true
pager.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
pager.topAnchor.constraint(equalTo: view.topAnchor, constant: 50).isActive = true
}
请帮忙,谢谢
【问题讨论】:
-
您的问题是什么?有错误吗?
-
问题是:我的收藏视图没有滚动它的内容:(没有任何错误
标签: ios swift scroll uicollectionview