I am using this chat layout from github. In that I am facing this scroll issue. When the content in the tableview grows, the new content must be visible automatically without being scrolled by the user. I don't know how to fix this bug in this framework.
Asked
Active
Viewed 74 times
1
-
Although it seems to be broad, logically this could be what are you looking for: https://stackoverflow.com/questions/33705371/how-to-scroll-to-the-exact-end-of-the-uitableview – Ahmad F Jul 12 '18 at 07:03
-
Possible duplicate of [UITableView , Scroll to bottom on reload?](https://stackoverflow.com/questions/5112346/uitableview-scroll-to-bottom-on-reload) – Abhishek Mitra Jul 12 '18 at 07:20
-
I checked out all the above questions, but when I add it , my app gets SIGABRT signal and crashes at the line which i added to move to bottom. – sharon Jul 12 '18 at 07:33
-
here the tableview is not of type uitableview. it is of type Lynnbubbletableview. How to fix it? – sharon Jul 12 '18 at 09:55
1 Answers
3
I go through your library.Please add these line of code for scrolling to the last position.
After self.tbBubbleDemo.reloadData():
let lastSectionIndex = self.tbBubbleDemo!.numberOfSections - 1
// Then grab the number of rows in the last section
let lastRowIndex = self.tbBubbleDemo!.numberOfRows(inSection: lastSectionIndex) - 1
// Now just construct the index path
let pathToLastRow = IndexPath(row: lastRowIndex, section: lastSectionIndex)
// Make the last row visible
self.tbBubbleDemo?.scrollToRow(at: pathToLastRow as IndexPath, at: UITableViewScrollPosition.none, animated: true)

Sanjukta
- 1,057
- 6
- 16
-
I tried it , but SIGABRT is called and my app crashes at line "self.tableView.scrollToRow(at: indexPath, at: .bottom, animated: true)" – sharon Jul 12 '18 at 07:32
-
here the tableview is not of type uitableview. it is of type Lynnbubbletableview. How to add this patch to my code? – sharon Jul 12 '18 at 09:54