1

In my normal tableview I got a bunch of switches and segments, and I don't want them to be selectable, so I set:

tableView.allowsSelection = FALSE;

Now one of the cells, I want to point to a new view, and thereby make it selectable. But there's no cell.allowSelection or anything, how do I solve this? How do I make it, so that it can be pushed and direct you to another view? I don't want them all to be selectable, since that's ugly...

pgSystemTester
  • 8,979
  • 2
  • 23
  • 49
John Kofod
  • 196
  • 1
  • 13

1 Answers1

3

There is not an allowsSelection property on cells, but there is a similiar property.

Set cell.selectionStyle to UITableViewCellSelectionStyleNone for cells you don't want to the user to be able to select.

(You will have to set table.allowsSelection back to YES.)

Configured this way, you'll still get -tableView:didSelectRowAtIndexPath: for any cell the user taps; just ignore it for cells that you don't intend to be selectable. (Thanks tc.)

Steven Fisher
  • 44,462
  • 20
  • 138
  • 192
  • 2
    The user *can* select those cells (you still get -tableView:didSelectRowAtIndexPath:); it's just not visible. – tc. Oct 13 '10 at 23:30
  • Yes, you just ignore those selections. If the selection doesn't appear and doesn't do anything, it might as well not be there. I'll add a note about that, though. :) – Steven Fisher Oct 14 '10 at 01:04
  • Works like a charm. And thanks tc, for pointing out the fact that the delegate gets called anyway... – John Kofod Oct 14 '10 at 18:08