I would like to load my tableview backwards, meaning the the tableView loads from bottom and scroll up to see more content.
First, I tried reversing the dataSource array. The contents are reversed, but, it still loads from the top, and the user has to scroll down to see more content.
I then tried loading the tableView from the bottom in viewWillAppear:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if (self.conversationTableView.contentSize.height > self.conversationTableView.frame.size.height) {
let offset = CGPoint(x: CGFloat(0), y: CGFloat(self.conversationTableView.contentSize.height - self.conversationTableView.frame.size.height))
self.conversationTableView.setContentOffset(offset, animated: true)
}
}
This attempt, however does not work since I am asynchronously downloading images (I'm using NSTextAttachment, which fills my UITextView within each cell). Everytime my placeholder is replaced with the real downloaded image, it causes the tableView content offset to shift (the placeholder's image height is almost always smaller than the height of downloaded image). So setting the contentOffset this way does not work.
How does one load the tableView from the bottom and scroll up to see more content?