Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS UITableViewCell needs to be pressed twice to call didSelectRowAtIndexPath

I have a UITableView that sometimes requires you touch it twice to select a cell.

More specifics:

  • Two touches are needed only after the table has been scrolled all the way up or all the way down.
  • Only the second touch even calls didSelectRowAtIndexPath.
  • When the table opens in the natural "scrolled up position", cells are indeed selectable with just one touch.
  • If you scroll just a little bit (not all the way down/up), the cells will select with just one touch.
  • If cells do not fill the whole table and scrolling is not required, it works fine.
  • Go all the way to the top or bottom and you have to touch twice.

I have a feeling that the first touch is really making the UITableViewCells selectable or is activating the table in some way.

Things I have checked:

  • My code definitely doesn't call didDeselectRowAtIndexPath anywhere.
  • No UIGestureRecognizers are using setCancelsTouchesInView:.

Other settings on the table:

self.tableView.scrollEnabled = YES;
self.tableView.showsVerticalScrollIndicator = NO;
self.tableView.bounces = NO;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;

What's causing this?


Update

Oddly enough, setting self.tableView.bounces = YES; fixed the problem.

I am still looking into the root cause in case anyone has a better answer. Obviously I would like for the table not to bounce, but not if it costs key functionality.

like image 402
kraftydevil Avatar asked Oct 14 '14 02:10

kraftydevil


1 Answers

May be you implemented didDeselect instead of didSelect?

like image 69
Vũ Ngọc Giang Avatar answered Nov 04 '22 11:11

Vũ Ngọc Giang