When exactly is this method called ? Suppose at a time I have 4 of my tableview cells visible on the screen then for how many cells will this method be called. Also, what if a cell is partially visible, will the method be called for the next cell as well in this case ?
P.S. I am not stuck anywhere, so showing some code doesn't make any sense. Its just a fundamental doubt.
The most simple explanation I can give you is - cellForRowAtIndexPath
, will call when a cell is about to be shown in the screen of your view controller. So this condition is valid whenever
[tableview reloadData]
, thus every cell will be dequeued/ populated again. numberOfRows
. If your View Controller has a tableview in the storyboard. This is called in viewDidLoad
as when the VC inspects a tableview in the storyboard, it will call the mandatory tableview datasource numberOfRows
first and then it will call cellForRowAtIndexpath
, that amount of time, the number of cells visible in the screen.Hope could solve your confusion.
This method will called for the number of time for your number of cell visible.
Suppose current 4 cell visible(row0,row1,row2,row3). it call for 4 time.
when you scroll and now again visible 4 cell like (row2,row3,row4,row5). It again for 4 time for row 2...5.
So this method will call for each visible cell in tableview every time when your scroll table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With