【发布时间】:2015-04-08 21:19:32
【问题描述】:
在用户向提要添加评论后,我试图滚动到表格视图的最后一行:
self.loadDataFromParse();
// load the last row
let numberOfSections = self.tableView.numberOfSections()
let numberOfRows = self.tableView.numberOfRowsInSection(numberOfSections-1)
if numberOfRows > 0 {
println(numberOfSections)
let indexPath = NSIndexPath(forRow: numberOfRows-1, inSection: (numberOfSections-1))
self.tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: UITableViewScrollPosition.Bottom, animated: true)
}
但tableview 只能滚动到大约一半/ 3/4。
任何意见表示赞赏
【问题讨论】:
-
我会得到该 indexPath 处单元格的
UITableViewCell。看看它是否是最后一个单元格。 -
不太清楚你的意思,你会怎么做?
-
UITableViewCell cell = self.tableView.cellForRowAtIndexPath(indexPath)检查有关此单元格的信息。看看它是否确实是表格中的最后一个单元格。因为它只滚动了 3/4,所以这似乎是第 3/4 个单元格吧? -
谢谢,试过了,我得到的行数 = 21,但是对于单元格:如果让单元格:TimelineCell = self.tableView.cellForRowAtIndexPath(indexPath)?作为? TimelineCell{ println("最后一行 cmets: (cell.postLabel?.text)"); ......我得到零......
标签: uitableview swift scroll