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