0
我有顶部的tableView有三排,现在我想我的小区2移动到的tableView的顶部,这样小区1变得完全看不见(出的tableView边界的)滚动一个UITableViewCell的实现代码如下
这是我的尝试:
func textViewDidBeginEditing(textView: UITextView) {
let index = NSIndexPath(forItem: 1, inSection: 0)
tableView.scrollToRowAtIndexPath(index, atScrollPosition: .Top, animated: true)
}
上面什么也没做,也许我失去了一些东西有
我也试过这样:
func textViewDidBeginEditing(textView: UITextView) {
let cgpoint = CGPointMake(0, (CGFloat(-64 - (channelCellRowHeight)))) // channelCellRowHeight is the hight of my row which i want move outside the tableview so that cell2 can stay at top of tableview
// here cgpoint is not accurate
tableView.setContentOffset(cgpoint, animated: true)
}
我不知道,必须有更简单的方法来做到这一点有点像 scrollRowToTop
API
任何线索我如何能实现我想要什么?
你需要计算你想要移动到顶部的所有单元格的高度,并将它们设置为你的contentOffset的Y位置 –
你找到了解决方案吗? –
man我在计算我的行高时遇到了问题,这就是我在做的:'let frame = tableView.rectForRowAtIndexPath(NSIndexPath(forRow:0,inSection:0)) defaultRowHeight = frame.height' @MohammedShakeer但那么该怎么做?导致我的默认contentOffset是'(0.0,-64.0)'(当tableView行在他们的默认位置) –