滚动到 table 视图的最后一行只会滚动一半
Scrolling to last row of table view only scrolls half way
我正在尝试在用户向供稿添加评论后滚动到 table 视图的最后一行:
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。
我使用页脚视图向提要添加评论,所以我在这里使用了它的高度,表格视图将滚动到页脚视图正上方的最后一行:
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;
我正在尝试在用户向供稿添加评论后滚动到 table 视图的最后一行:
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。
我使用页脚视图向提要添加评论,所以我在这里使用了它的高度,表格视图将滚动到页脚视图正上方的最后一行:
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;