Add helper scroll methods
andrefmsilva opened this issue · 1 comments
andrefmsilva commented
I know this is a bit out of context of the framework, but some methods to scroll the target to a specific section id or cell id are really useful.
ra1028 commented
That can be done with the following simple code:
enum SectionID: CaseIterable {
case first, second, third
}
// render sections with order same as SectionID.allCases
renderer.data = SectionID.allCases.map { id in
Section(id: id, header: ..., footer: ..., cells: ...)
}
// take section index from allCases
if let index = SectionID.allCases.firstIndex(of: .second) {
let indexPath = IndexPath(item: 0, section: index)
// scroll to the top of row in the specified section
tableView.scrollToRow(at: indexPath, at: .top, animated: true)
}