我可以在UITableView中添加带有伪数据的临时单元格吗? [英] Can I add a temporary cell with dummy data in UITableView?

查看:73
本文介绍了我可以在UITableView中添加带有伪数据的临时单元格吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以添加一个带有数据的虚拟单元格,直到应用程序从服务器获取真实数据,然后将其删除并替换为真实数据?

Is there any way that I can add a dummy cell with data until the app fetches the real data from the server, then delete it and replace it with real data?

我这样做是因为花很长时间才能获取数据,而且应该是聊天室.

I'm doing this because it takes too long to go and get the data and it is supposed to be a chatroom.

推荐答案

是的,您可以执行此操作.例如,如果您使用数组填充 UITableView ,则可以用虚拟数据填充该数组.然后,当您从服务器收到真实数据时,可以在适当的索引处替换虚拟数据,然后调用 reloadData 重新加载表并使用正确的数据更新单元格.

Yes, you can do this. For example, if you're using an array to populate your UITableView, you can fill that array with the dummy data; then when you receive the real data from the server, you can replace the dummy data at the appropriate indices then call reloadData to reload the table and update the cells with the correct data.

这篇关于我可以在UITableView中添加带有伪数据的临时单元格吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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