I am trying to have the selection color, based on row, be different. Defining a color in the selection theme will change all of my rows when selected to the same color. I would like my rows to be a different color based on row. Specifically, I am trying to make it look like the rows are not being selected at all. Because I am using the data source helper, and alternating colors(white & blue), the only alternative I have found to make the rows still selectable, and not appear as though they are changing colors, is to use the willDisplayCell method which I have displayed below:
-(void)gridView:(IGGridView*)gridView willDisplayCell:(IGGridViewCell*)cell forPath:(IGCellPath*)path{
//overwrite selected color, makes row colors not change when selected
NSColor *cellColor= cell.backgroundColor
cell.selectedColor = cellColor;
}
However, if my rows exceed beyond the views scrollview, and I scroll down, the cells IGCellPath will be reset to the new viewable cell, which causes my selected colors to be skewed. IE. if my fifth row is not viewable, but then I scroll to have it be the first row from the top of my gridView, it's new rowPath is now 1, instead of 5. I will then notice that if I select a white row, it will sometimes be blue, and vice versa. I assume this caused by dequeResuableCell, which is a function I will still need to implement.
I am not sure if I have missed alternative methods/properties, or could implement willDisplayCell in a better fashion. Is there any other way to have my rows with alternating colors still be selectable, but retain the current background color for each row?
Hi Brett,
If i'm understanding the issue correctly, it sounds like you just want to set the cell's selected color to [UIColor clearColor]
-SteveZ
Ok, ignore my last answer. I simply forgot that in order to keep the cell's light, we don't display another view, we simply display the cell's background color on top.
That being said, i'm a little confused by your description. Are you implementing a custom DataSource, or are you using the IGGridVIewDataSourceHelper?
Assuming you're using the DSH and still using themes, then you could modify your code to be:
-(void)gridView:(IGGridView *)gridView willDisplayCell:(IGGridViewCell *)cell forPath:(IGCellPath *)path
{
id<IGGridViewThemeDefinition> theme = gridView.theme;
cell.selectedColor = (path.rowIndex %2 == 0) ? [theme cellBackgroundColor] : [theme alternateRowCellBackgroundColor];
Perhaps that will do the trick?