I need to implement a grid to display some view objects on an iPad. To get the most out of the SDK, I thought I would use a UITableView to keep track of my rows, and then inject some kind of counter to return the correct columns to place in my cells.
The enumerator works fine. I just pass the tableViews viewController to a one-dimensional array, and the enumerator splits it into a “pseudo-two-dimensional set”, however I would like to make the grid approach similar to UITableViews for both rows and columns:
[tableView dequeueReusableCellWithIdentifier:CellIdentifier]
As now, I create the number of column views needed for each row, and add them manually to the cell in cellForRowAtIndexPath:
I would like to make a method called:
columnsForRowAtIndexPath:
and let it work like cellForRowAtIndexPath..
So the question is, how does tableView avoid initializing my cells over and over again and how can I implement this behavior?
-
I can't figure out if the tableView will copy cells or create new ones using NSCoding to return cells with minimal overhead. Guessing NSMatrix would be really nice to have in iOS.
source share