1

I set the Property of UITableview - "Show Selection On Touch" to YES in Interface Builder. But when I selected a row, the cell's style just changed its color to blue.

In some app which contains UITableview, when user selected a row,it will appear a '√' to represent that this row is selected.

I want to know how can I get this effect.

Thanks!

Solskjaer
  • 175
  • 1
  • 11

2 Answers2

1

You can use the accessoryType property to toggle between UITableViewCellAccessoryCheckmark and UITableViewCellAccessoryNone together with -didSelectRowAtIndexPath: method to do the toggling.

For details and examples, please see this post: UITableView, having problems changing accessory when selected

Community
  • 1
  • 1
PengOne
  • 48,188
  • 17
  • 130
  • 149
  • I'm assuming this would be helpful as well for the type of application your building. If you don't want the cell to be blue when it's selected set its `selectionStyle` to `UITableViewCellSelectionStyleNone`. – Espresso Jul 11 '11 at 04:17
0

In

- (void)tableView:(UITableView *)tV didSelectRowAtIndexPath:(NSIndexPath *)indexPath

do:

UITableViewCell *cell = [tV cellForRowAtIndexPath:indexPath]; 

cell.accessoryType = UITableViewCellAccessoryCheckmark;
jakev
  • 2,815
  • 3
  • 26
  • 39