Created
October 25, 2018 12:14
-
-
Save mischa-hildebrand/aef5e87f2f9e7f9a5b6a06f5305f939a to your computer and use it in GitHub Desktop.
Updating the UI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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