问题
After using
beginUpdates()
endUpdates()
This method ->
tableView.setContentOffset(_, animated:) // do not work
Do not work after calling that 2 methods (even if I use timer), but works without them! Any ideas why?
setContentOffset works only if I swipe tableView manually after beginUpdates() + endUpdates()
and BEFORE setContentOffset
is being called.
scrollToRowAtIndexPath
works fine though but I need only setContentOffset
.
回答1:
tableView.setContentOffset(_, animated:)
works now when I calling with a dispatch to the main thread! So,
beginUpdates()
endUpdates()
DispatchQueue.main.async {
tableView.setContentOffset(CGPoint(x: 0, y: -offset), animated: true)
}
This way works.
来源:https://stackoverflow.com/questions/59631998/tableview-setcontentoffset-animated-do-not-work-after-beginupdates