2014-12-20 62 views
0

我正在使用以下代码来确定当您滚动时哪个UITableView行标题被卡住。这是工作的罚款,直到我为了增加我的表自定义顶部边界为表的内容最初坐在下面的我的观点之一:使用自定义UITableView插入时获取顶部单元格路径部分

func scrollViewDidScroll(scrollView: UIScrollView) { 
    let paths = tableView.indexPathsForVisibleRows() 
    let topCellPath: NSIndexPath = paths?.first as NSIndexPath 
    println(topCellPath.section) 
} 

的问题是,现在它没有报告在节头的变化,直到先前卡住的标题在导航栏下方远离/看不见。

我该如何更改代码,以便它仍然报告正确的顶部单元格路径部分/行标题即使在我的表上自定义顶部插入仍然卡住?

谢谢!

回答

0

结束了使用这其中“subNavView”就是我的UITableView顶部边界开始的观点:

let bounds = subNavView.bounds 
let localFrame = tableView.convertRect(bounds, fromView: subNavView) 
let point = CGPointMake(0, localFrame.origin.y + localFrame.size.height + 1) 
let topCellPath = tableView.indexPathForRowAtPoint(point) 
let topCellPathSection = topCellPath?.section 
相关问题