Question

I've built a UITableView with reusable cells. At some point in my code I need access to a cell at a certain indexPath, so I call

MyCell *cell = (MyCell *) [tableView cellForRowAtIndexPath:indexPath];

Sometimes (usually the first time) this is called, it may take from 0.5 to 1 second.

What can cause this and how can I preven this?

I checked if

(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

gets called as a reaction to cellForRowAtIndexpath: but it doesn't.

EDIT:

I just did another test and it also takes long if I call

  [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionMiddle];

Whatever gets called first, does have a lag of half a second

Was it helpful?

Solution

call [tableView reloadData] first, that may force the tableview to load its data. but still, if a cell is not visible on screen, it might not be loaded into memory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top