Is there a way to scroll the messages to the most recent message while going into the chat room. currently, i am reloading the Collection view and scroll to the bottom. In case of more messages, it firs show me the top message and then scroll and show me the most recent ones, i want it to take me to the bottom without showing me the top messages.
Also is there is any other way where we can store user scrolling positions and then show them exactly where they last were just like Whatsapp is doing.
try this to scroll the most recent messages without showing top messages first.
self.messagesCollectionView.reloadData() let indexPath = IndexPath(row: 0 , section: self.messageList.count - 1) self.messagesCollectionView.scrollToItem(at: indexPath, at: .bottom, animated: false)
Yeah i am doing the same. I just wanted to know if there is any other
better way to do it.
On Thu, 13 Feb 2020 at 1:11 PM, TayyabAli652 notifications@github.com
wrote:
try this to scroll the most recent messages without showing top messages
first.self.messagesCollectionView.reloadData()
let indexPath = IndexPath(row: 0 , section: self.messageList.count - 1)
self.messagesCollectionView.scrollToItem(at: indexPath, at: .bottom, animated: false)—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/MessageKit/MessageKit/issues/1244?email_source=notifications&email_token=AE572D36EF5UFAET6B2FLI3RCT6C5A5CNFSM4KTY2G5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELTZUJI#issuecomment-585603621,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AE572D542B4MQ56RZKQJPJTRCT6C5ANCNFSM4KTY2G5A
.
Not sure if solution above works for you, beacuse in my case I coudn't scroll to bottom in viewWillAppear and I end up with this workaround:
```
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
if !subviewsLoaded {
messagesCollectionView.reloadData()
messagesCollectionView.scrollToBottom()
subviewsLoaded = true
}
}
```
The viewDidLayoutSubviews workaround from @xsoti works for me.
Workarounds in viewWillAppear happened too late when using NSFetchedResultsController for loading messages and the first messages would flash briefly.
Workarounds with transforms to rotate views caused layout issues (margins not right in top and bottom), and the scroll bar got rotated to left.
This issue has been marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
I would like to keep this issue alive, I see this and my testers have commented on it.
i will try some of the work arounds mentioned above, but would def be nice to have it working out of the box
@lewis-smith, MessageKit does not provide or endorse any specific data layer for the message content, that is entirely up to you to implement and control. As such it doesn't make sense for MessageKit to provide an 'out-of-the-box' functionality. Any plain UICollectionView with many items could have the same UI/UX problem when loading/appearing on the navigation hierarchy, depending on how the data-source has been implemented.
Most helpful comment
Not sure if solution above works for you, beacuse in my case I coudn't scroll to bottom in viewWillAppear and I end up with this workaround:
```
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
```