0

I am trying to add a tick next to a user selection to indicate that the user has guessed at a particular place.

Currently, my logic allows for all cells to be clicked as can be seen below;

enter image description here

How can I limit the user to only have one selection enabled at any one time? I was thinking of having a variable (say an int) to track the currently selected - this way i can remove the tick in the correct places. However, I would like to know

1) is this the best way to do it and

2) How do i unselect (unhighlight) a previously selected cell.

Thanks

Would I need a class variable to see if it is assigned, if so then take do some log

Shruti Thombre
  • 989
  • 4
  • 11
  • 27
Biscuit128
  • 5,218
  • 22
  • 89
  • 149
  • 2
    possible duplicate of [UITableView Checkmark ONLY ONE Row at a Time](http://stackoverflow.com/questions/10192908/uitableview-checkmark-only-one-row-at-a-time) – Aaron Brager Oct 08 '14 at 14:05

2 Answers2

2

Limit the selection to one by setting

yourtableView.allowsMultipleSelection=false
Nofel Mahmood
  • 898
  • 7
  • 12
1

You could easy use:

tableView.allowsMultipleSelection = false
derdida
  • 14,784
  • 16
  • 90
  • 139
  • apparently this will not work - 2 reasons the first being on the storyboard selection is set to single already and secondly , when i use the code you posted in the viewdidload method it warns me saying `'UITableView' does not have a member named 'setAllowsMultipleSelection'` – Biscuit128 Oct 08 '14 at 14:10
  • Use tableView.allowsMultipleSelection = false – derdida Oct 08 '14 at 14:11