I am happily able to set the styling of my tableviewcells using the cellForRowAtIndexPath delegate, but I want to set the background of all the nonpopulated cells which are still on the screen
A:
hey, basically any cell which is part of your tableview belongs to a particular index and particular row
so incase you are not populating a particular section via data source - you can still get a reference to a cell in that indexPath by manually calling the cellForRowAtIndexPath delegate, and passing the section as well as row index
it returns you a cell. assign it to your private variable and edit it the way you want to.
Raj
2009-03-31 13:55:42
I have tried this but because my data source is bound to the table (length of 5) any cells outside of that length return the error: index (10) beyond bounds (5)
tigermain
2009-03-31 14:10:46
tigermain - your question or your code is probably incorrect then. basically your tableview only has x number of rows (which you specify) via numberOfRowsInSection delegate. and if you specify the right number, then you can get a reference to ANY CELL IN ANY SECTION which exists
Raj
2009-03-31 14:15:43
I define an array of strings, then return the length of this in numberOfRowsInSection. This then restricts the number of elements to 5 in this case, but the table view is large enough to display abut 10 records
tigermain
2009-03-31 14:47:56
okay, you cant get a reference to these extra cells then (because they are never instantiated by tableview data source). i think you should have mentioned this in your question clearly :-)
Raj
2009-03-31 15:03:55
I did say for the NON-Databound cells in the title
tigermain
2009-04-06 14:05:38
A:
Use the visibleCells
method on your table view. Then do what you wish to the cells.
Alternately, you could call indexPathsForVisibleRows
to get just the index paths. Then call cellForRowAtIndexPath:
to get the cell corresponding to each index path.
Chris Lundie
2009-03-31 14:23:12