I use for my app UITableview
and I got a problem.
Method tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
called only by sliding finger from left to right or from right to left the item. But when I do normal click by this item, this method doesn't called

- 69,473
- 35
- 181
- 253

- 31
- 1
- 6
-
2Did you set the delegate and datasource correctly? – thxou Mar 30 '16 at 10:58
-
I think, I did it correctly because this method gets a call but not by click) – Martin Gut Mar 30 '16 at 11:00
-
Check this post. Maybe helps you... http://stackoverflow.com/q/255927/6124910 – Patrick Mar 30 '16 at 11:01
-
also didn't help :( very strange – Martin Gut Mar 30 '16 at 11:11
-
can't you show your code for implement data source and your delegate ? – vien vu Mar 30 '16 at 11:16
-
http://prntscr.com/alym8l , http://prntscr.com/alymfa - screenshots – Martin Gut Mar 30 '16 at 11:33
-
Did you set value single selection in selection property of tableview ? – Hiren Dhamecha Mar 30 '16 at 11:45
-
Do you have a button or another UIControl which is hogging up tap events / touches. Try setting `UserInteractionEnabled = false;` for all content in the cell. – Swapnil Luktuke Mar 30 '16 at 12:04
-
I changed all content inside cell to UserInteractionEnabled = false and it didn't help – Martin Gut Mar 30 '16 at 12:17
-
I once (mistakenly) implemented `-tableView:did**Deselect**RowAtIndexPath:` instead of `-tableView:did**Select**RowAtIndexPath:` (I chose the first autocomplete candidate that popped up without reading carefully). – Nicolas Miari Mar 31 '16 at 06:38
1 Answers
What is supposed to do the cell when you click on it?. As a first impression, the line tableView.deselectRowAtIndexPath(indexPath, animated: false)
is not animating the select of the cell, and that can cause the impression that nothing is happening.
Second, the implementation of the cellForRowAtIndexPath:
and didSelectRowAtIndexPath:
methods look almost the same. I mean, in both methods your are getting the same data from the categories
array and not changing anything, at least that's what I can see with the code you provided.
Third, may the implementation of the code inside your subclass, to which item
belongs to in let item = categories[indexPath.row]
, be wrong.
Fourth, why your code have semicolons?.
You can review all of these to start discarding.

- 691
- 7
- 20