Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mischa-hildebrand/aef5e87f2f9e7f9a5b6a06f5305f939a to your computer and use it in GitHub Desktop.
Save mischa-hildebrand/aef5e87f2f9e7f9a5b6a06f5305f939a to your computer and use it in GitHub Desktop.
Updating the UI
extension MessagingViewController: MessagingDataSourceDelegate {
func dataSourceDidUpdate() {
tableView.reloadData()
scrollToLastMessage()
}
private func scrollToLastMessage() {
let rowCount = tableView.numberOfRows(inSection: 0)
if rowCount > 1 {
let lastIndexPath = IndexPath(row: rowCount - 1, section: 0)
tableView.scrollToRow(at: lastIndexPath, at: .bottom, animated: true)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment