ios - 检测滚动的tableviewcell

标签 ios swift xcode

我有一个表格 View ,每个单元格都包含一个 Collection View 。当用户滚动集合时,如何检测相应的单元格?

    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {

    if (lastContentOffset.x < (scrollView.contentOffset.x)) {

        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "scrolledRight"), object: nil)

    }

}

最佳答案

最好的方法应该是像这样创建一个委托(delegate)

protocol TableCellScrollDelegate {
   func didSrcoll(cell : UITableViewCell, offset : CGPoint)
}

在您的 TableViewCell 类中,实现 UIScrollViewDelegate,然后使用协议(protocol)转发消息。

关于ios - 检测滚动的tableviewcell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47527226/

相关文章:

ios - 使用 for-in 循环枚举

ios - 如何使用 PKAddPassButton 添加 "Add to Apple Wallet"按钮 - swift

ios - 无法将自定义类数组保存到 UserDefaults

swift - 如何在 Swift 中从 UIImagePickerController 获取编辑后的图像?

ios - 在 Swift 中制作 Gif 动画

iphone - 奇怪的 iOS 导航应用程序崩溃

swift - Gamescene.swift 和 Gamescene.sks 不能一起工作

ios - libc++abi.dylib : terminating with uncaught exception of type NSException on iOS 7. 1

ios - 如何从一对多关系中正确检索 .allObjects

ios - UILabel 找到适合宽度的高度