what is reloadData function? [closed]

无人久伴 提交于 2019-12-25 02:19:45

问题


every one. I'm a new for iphone.

I saw some document for iphone develop, but I don't understand the [xxx reloadData]; with tableView yet.

When i use this method, my all cells are cleared. What happened?

I don't understand it.


回答1:


It means you force the UITableView to get the data and refresh itself. It is what you wanna do after you changed something in your data source.

For example, I have a NSMutableArray of three objects a, b and c. I have a button to delete an object, say b. After I pressed my button and get object b deleted from my array, my table view won't reload unless I call [myTableViewName reloadData] to force it refresh itself.

If after you do [xxx reloadData], you got nothing. It means, your data needed for the table view is not there anymore. So track the data source and see if the data got changed.




回答2:


As the documentation indicates, reloadData will simply force the list to refresh by querying your datasource and delegate. Please see http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableView_Class/Reference/Reference.html and post some code if you have problems.



来源:https://stackoverflow.com/questions/10823355/what-is-reloaddata-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!