Welcome, Guest
Username Password: Remember me

Showing cells as selected
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Showing cells as selected

Showing cells as selected 1 year, 8 months ago #1

I am using a SCTableViewModel in the simplest possible way - just as a one level menu in an iPad split view controller. The mechanics of the table are working as described, but the cells do not show highlighted when they are selected.

I have implemented

 
- (void)tableViewModel:(SCTableViewModel *) tableViewModel didSelectRowAtIndexPath:(NSIndexPath *) indexPath
 


which is firing at the correct time. Inside that function I have:

 
SCTableViewCell *theCell = [tableModel cellAtIndexPath:indexPath];
theCell.selectionStyle = UITableViewCellSelectionStyleBlue;
theCell.selected = YES;
 


which ought to set the cell as highlighted, but it doesn't seem to do anything. Am I missing something?

Thanks!
  • ulfie22
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
  • Karma: 0

Re: Showing cells as selected 1 year, 8 months ago #2

It seems that you're using an SCTableViewCell subclass that has it's selectionStyle set by default to UITableViewCellSelectionStyleNone (e.g. an SCLabelCell). You don't actually need to implement the didSelectRowAtIndexPath method. The following code should be sufficient:

 
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
willConfigureCell:(SCTableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
SCTableViewCell *theCell = [tableModel cellAtIndexPath:indexPath];
theCell.selectionStyle = UITableViewCellSelectionStyleBlue;
}
 


Hope this helps.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: Showing cells as selected 1 year, 8 months ago #3

Thanks - that worked perfectly. I still use the didSelectRowAtIndexPath: method to actually trigger the action, but the coloring of the selected cells works just like I want. Thanks!!!!!
  • ulfie22
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
  • Karma: 0
  • Page:
  • 1
Time to create page: 1.44 seconds