I have an app with a UITableViewController
, initially with a single section with a single row (that says "Loading..." in it). It fetches some data from the internet, at which point it makes the following call:
[tableView reloadSections:[NSIndexPath indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];
This is necessary because after fetching the data, there's now a lot of rows, rather than just the 1 there was initially (so asking the table view for the list of visible cells isn't a possibility, since it just returns the 1 old one)
The trouble is that it's then calling the cellForRowAtIndexPath
delegate method for every single row, not just the visible ones. I've verified that by putting some logging into the method. If I switch the line to a simple [tableView reloadData]
then it only calls cellForRowAtIndexPath
for the first few rows, until the point where you scroll and others come into view. This happens on my iOS4 iPod Touch and also in the iOS5 simulator.
I have about 300 rows and it's making it very slow to load and usually crashes on my iPod Touch.
The reason I'm not just using reloadData
is that I want the addition of the new rows to be animated, whereas reloadData
just makes them suddenly appear.