2

So here's my strange problem.
I have a small app which uses storyboard.
I have 1 UITabBarController which has 2 tabs:
- 1 UITableViewController(subclassed)
- 1 UIViewController(just has a UILabel and does nothing till now)

The UITableViewController is subclassed and i provided:
- numberOfSectionsInTableView(tableView: UITableView) -> Int
- tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
- tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath)
- tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell

The tableview has 2 sections (7 and 1 row).
The rows in section 1 are custom cells and should do nothing when selected.
The row in section 2 is a standard UITableViewCell and should start a download.
But When i selecting any cell tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath)isn't even called, only after selecting another cell(not the same again), the didSelect will be called with the first cell i selected.
Another example; (x,x) is representing the selected indexPath
(1,0), does nothing -> (0,6), (1,0) is selected -> (0,2), (0,6) is selected -> (1,0), (0,2) is selected

Additions:
- The highlighting is working as it should. Just the call of tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) isn't.
- tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? is called appropriate.

Solution:
Was a little typo in the delegate method. I implemented didDeselectRowAtIndexPath instead of didSelectRowAtIndexPath

manuelwaldner
  • 551
  • 1
  • 5
  • 24

2 Answers2

6

You are calling didDeselectRowAtIndexPath instead of didSelectRowAtIndexPath. You should use this method :

tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
iRiziya
  • 3,235
  • 1
  • 22
  • 36
1

Please check your delegate method, it should be;

tableView(tableView: UITableView, selectRowAtIndexPath indexPath: NSIndexPath)
ugur
  • 824
  • 1
  • 7
  • 15
  • 1
    there is no selectRowAtIndexPath method in the UITableViewDelegate protocol. willSelectRow exists and is called appropriate, just the didSelect isn't called, from the other anwser i might know what you meant – manuelwaldner Aug 14 '15 at 05:57
  • Sorry, it's didSelect. See the answer below for exact syntax. You can check the delegate definition. – ugur Aug 14 '15 at 05:59