Table Contents not Visible Until Table Scrolls
I am new to iph开发者_运维百科one Development. I am parsing XML into a mutable array of strings which displays dynamically in a table. I am not able so see the content in the table but as soon as I scroll down the contents are displayed. Please help me out.Thanks
Can't say for certain without seeing the code but it sounds like – tableView:cellForRowAtIndexPath:
returns empty cells at first. Most likely it does so because your datasource, in this case the xml parser, has not yet provided data for the cells when the table first loads.
The table only populates the visible rows and then stops. It only fetches more data when you scroll and new cells become visible. In your case, it sounds like the table has no data when it first loads but in the time it takes you to manually scroll it, it has found the data.
You probably need to call reload
on the table to force it load the data. Even better, you should alter your design to make sure it has some data to display before the table itself loads. If that is not possible, you should have some placeholder information in the cells e.g. text that says "Loading Data..." and then call reload
.
The problem is that when you finish parsing your XML file, you don't reload your table that is already visible.
You have to use something like
[myTableView reloadData];
right after finish parsing the XML file.
Cheers,
VFN
精彩评论