在用户向提要添加评论后,我试图滚动到表格 View 的最后一行:
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 的位置。
任何输入表示赞赏
最佳答案
此解决方案可能对遇到相同问题的其他人有所帮助。 此问题是一个错误,请参阅讨论 here .
我使用页脚 View 向提要添加评论,所以我在这里使用了它的高度,表格 View 将滚动到页脚 View 正上方的最后一行:
self.tableView.reloadData();
// load the last row
let offset = CGPoint(x: 0, y: self.tableView.contentSize.height - self.tableView.frame.size.height + self.FOOTERHEIGHT);
self.tableView.contentOffset = offset;
关于uitableview - 滚动到表格 View 的最后一行只会滚动一半,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29525548/