动态更改UITableView的内容 [英] Dynamically Changing UITableView's Contents
问题描述
我有一个NSURL对象,它根据用户在搜索栏中输入的变量从我的网站获取数据.
I have an NSURL object which gets data from my site, based on a variable entered by the user into the search bar.
我将此数据拆分为一个NSArray.
I split this data into an NSArray.
完成后,我希望在UITableView中显示数据.
Once I have done that I wish to display the data in a UITableView.
我的问题是这个.是否可以动态地将数据加载到UITableView中?
My question is this. Is it possible to load the data into a UITableView dynamically?
即程序加载时没有数据,因此UITableView为空,然后用户搜索一个变量.获取一些数据,并将其内容加载到UITableView中.搜索新变量,是否从UITableView中清除了旧数据并添加了新数据?
i.e. Program loads, no data so UITableView is empty, then the user searches for one variable. Gets some data and the contents is loaded into the UITableView. Searches for a new variable, old data is cleared from UITableView and the new data is added?
我目前正在尝试使用界面生成器来执行此操作,但是担心我可能必须实用地创建我的界面,以便可以销毁并重新创建UITableView,但是我不确定.
I'm currently trying to do this using interface builder, but fear that I may have to make my interface pragmatically, so that I could destroy and re-create the UITableView, but i'm, not sure.
感谢您的帮助.
推荐答案
确保UITableView上的reloadData方法可以解决问题
Sure the method reloadData on UITableView will do the trick
这篇关于动态更改UITableView的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!