使用firebase聊天时如何从下到上设置数据 [英] How to set data from bottom to top while chat using firebase

查看:28
本文介绍了使用firebase聊天时如何从下到上设置数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 firebase 聊天应用程序,我设计了我的布局并成功实现了聊天模块,但是,问题是当我发送短信时它工作正常并将文本数据设置到 collectionView 的底部,但是当我关闭我的应用程序并打开时再次设置文本数据不匹配,最后一条消息向上.

I am working on firebase chat app, i designed my layout and implemented chat module successfully but, the problem is when i send text message it works fine and set text data to bottom of the collectionView but when i close my app and open it again the setting of text data mismatch and the last message comes upward.

我尝试了所有堆栈溢出问题,其他人也尝试过,但没有任何变化.无法反转数据

I tried all stack overflow questions and others try's but nothing happens any change. can't reverse data

推荐答案

以相反的顺序填充数组,因为当您将数据插入数组时,您会在数组的零索引处插入最后一条消息,因此在集合视图中以相反的顺序填充数组例如 Array.reverse 或者您可以以相反的顺序将数据插入数组,例如在数组的最后一个索引上插入最后一条消息.如果您有任何问题,请告诉我.

Populate your array in reverse order, Because when you inserting data into array you insert last message at zero index of array, so populate array in reverse order on collection view e.g Array.reverse or you can insert data in reverse order into you array, e.g insert last message on last index of array. If you've any issue let me know.

这篇关于使用firebase聊天时如何从下到上设置数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆