ios - 如何触发 scrollViewWillEndDragging 事件?

标签 ios uitableview swift uiscrollview

我有一个 View 覆盖在 UITableView 的顶部。但是当用户在顶部 View 上拖动时,我需要触发 UITableView 事件的滚动事件。

我在 View 上添加了 UIPanGestureRecognizer,并在使用 setContentOffset 时成功触发了 scrollViewDidScroll 事件:

@IBAction func handleScroll(sender: UIPanGestureRecognizer)
{
    if sender.state == UIGestureRecognizerState.Changed
    {
        let transtion = sender.translationInView(self.contentViewContainer)

        tableViewController.tableView.setContentOffset(CGPointMake(0, 0 - transtion.y), animated: false)
    }
}

// UITableView delegate
override func scrollViewDidScroll(scrollView: UIScrollView)
{
    // this will be called while using setContentOffset.
}

但是对于这种情况,我该如何触发 scrollViewWillEndDragging 事件呢?

@IBAction func headerScroll(sender: UIPanGestureRecognizer)
{       
    if sender.state == UIGestureRecognizerState.Ended
    {
        // Do what?
    }
}

override func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>)
{
    // To trigger this?
}

最佳答案

为什么不跟踪 tableview 而不是 scroll。

tableView:didEndDisplayingCell:forRowAtIndexPath:

此方法将在每个单元格显示后调用。

关于ios - 如何触发 scrollViewWillEndDragging 事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27577163/

相关文章:

ios - 为什么 Unity3D 应用程序 [导出到 Xcode 项目] 会因为 ip_unity_plugin.bundle 有 "unsealed contents present in the bundle root"而失败?

objective-c - NSLocalizedString 不起作用

ios - 如何通过 Xcode 中 UITests 下的标识符访问详细信息披露按钮?

swift - 如何在 Swift 中存储对整数的引用

iOS 动态单元格内容

iphone - SIGTRAP 在 iOS 6.1.3 上选择特定的 UITableViewCell

iphone - willSelectRowAtIndexPath/didSelectRowAtIndexPath 混淆

ios - 向 UITableView 添加多个页脚

ios - UIImage 数组中数百张图片 - 内存泄漏

ios - 无法使用 Alamofire 检索确切的查询响应