【发布时间】:2020-03-04 07:54:24
【问题描述】:
我正在为我的应用创建自定义集合视图。
我想在 ViewController 上滚动 CustomCollectionView 时调用 scrollViewWillEndDragging 方法。
当它在屏幕上绘制 CustomCollectionView 时,调用了 CommonInit,但是当我滚动它时没有调用 scrollViewWillEndDragging。
我怎么称呼它?
这是我的代码。
在自定义视图中
class CustomView: UICollectionView {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
func commonInit() {
…
}
}
extension CustomView: UIScrollViewDelegate {
// want to call this method
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>)
{
}
在 AViewController 中
class AViewController: UIViewController {
@IBOutlet weak var collectionView: CustomView!
…
override func viewDidLoad() {
…
collectionView.register(UINib(nibName: "Cell", bundle: nil), forCellWithReuseIdentifier: "Cell")
…
}
}
【问题讨论】:
标签: ios swift uicollectionview uiscrollview