2
我用下面的两个方法,他们都在工作,但我提到的问题。tableView滚动到底部不显示最后一部分,不得不手动滚动它,有谁知道吗?
延伸的UITableView {
func scrollToBottom() {
let sections = numberOfSections-1
if sections >= 0 {
let rows = numberOfRows(inSection: sections)-1
if rows >= 0 {
let indexPath = IndexPath(row: rows, section: sections)
DispatchQueue.main.async { [weak self] in
self?.scrollToRow(at: indexPath, at: .bottom, animated: true)
}
}
}
}
func moveToLastComment() {
if self.contentSize.height > self.frame.height {
let lastSectionIndex = self.numberOfSections - 1
let lastRowIndex = self.numberOfRows(inSection: lastSectionIndex) - 1
let pathToLastRow = NSIndexPath(row: lastRowIndex, section: lastSectionIndex)[enter image description here][1]
self.scrollToRow(at: pathToLastRow as IndexPath, at: UITableViewScrollPosition.bottom, animated: true)
}
}
}
setContentOffset(CGPoint(X:0,Y:contentSize.height),动画:真) – SeanLintern88
与功能你在挣扎吗?两者都滚动到最后一个单元格。你可以附上一些'gif'来解释你的问题吗? – dirtydanee