views:

119

answers:

1

Hello,

I am using UITableView in my application. I am using the cellForRowAtIndexPath method of the UITableView control.

My question is that why this method cellForRowAtIndexPath is called whenever I scroll the table.

+2  A: 

Only the visible cells are requested. If you scroll the table, it will generate the new ones that come into view...

cmaughan
Thanks, but if I want to generate all the cells at once for the table?
pratik
What do you need that for? Existing approach (and reusing cells) is a great optimization really.
Vladimir
If you want to build your table information once, then I suggest you build a data structure to hold the information you need, then look it up when the table cell comes into view. Put it in an NSDictionary, or whatever...
cmaughan
cmaughan, can you please give the code for the same?
pratik
http://developer.apple.com/iphone/library/samplecode/TableViewSuite/index.html
cmaughan