[英]rebuild table cells in UITableViewController
I have a UITableViewController that when loaded gets data from a web-service and stores it locally in an NSMutableArray, once that is loaded I need to loop through that data to build my table cells. 我有一个UITableViewController,在加载时从Web服务获取数据并将其本地存储在NSMutableArray中,一旦加载,我就需要遍历该数据来构建我的表单元格。
I have all of the code for looping through my array working fine I just need to know how to fire my controller to rebuild the table so my it displays my data. 我有所有遍历数组的代码都可以正常工作,我只需要知道如何触发控制器来重建表,以便它显示我的数据即可。
[self.tableView reloadData];
After saving the datas in mutatable array after calling webservices, call tableview reloadData 调用Web服务后将数据保存在可变数组中后,调用tableview reloadData
[self.tableView reloadData];
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [datas count];
}
Make sure that you update the mutable array "datas" value after storing content in mutable array, such as datas will have the web service contents. 将内容存储在可变数组中后,请确保更新可变数组的“数据”值,例如数据将具有Web服务内容。
Here is sample program of parsing and displaying the parsed content in table, you can refer it how they are reloading their table after parsing 这是解析并在表中显示已解析内容的示例程序,您可以参考解析程序如何在解析后重新加载其表
All the best. 祝一切顺利。
I ended up following the instructions here for creating a UITableViewDataSource class, works like a champ! 我最终按照这里的说明创建了一个UITableViewDataSource类,就像冠军一样!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.