CocoaDev

Edit AllPages

Here’s sample code that shows how to reselect cells after rows or columns have been added/removed from a matrix. This issue pops up when you enclose a matrix in a scroll view and then you would like the matrix’s width to fit the content width of the scroll view. If you resize the matrix while also enforcing a minimum cell width, you will have to add and delete rows and columns accordingly. If you would like the state of each cell to persist after rows/columns have been added/removed, you have to record the indicies of the selected cells before the matrix’s row/column count is altered and then reselect the cells after rows/columns have been added/removed.

This sample code is for a custom matrix method that adds/removes rows/columns when its enclosing scroll view’s content size changes.

}

–zootbobbalu