22

I have a UITableView that draws a subView when the user touches a cell.

The problem is that the subView drawing is animated and if the user is fast enough they can tap a cell multiple times which I want to disable during the animation and afterwards.

I've tried using this:

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

    [[UIApplication sharedApplication] beginIgnoringInteractionEvents];

and also a bool variable:

if (isAnimating == NO) {

but neither seem to work. In each case rapid touches screws up everything.

Any help would be great thanks!

itgiawa
  • 1,616
  • 4
  • 16
  • 28

2 Answers2

42

Try this... After clicking on cell set

tableView.userInteractionEnabled = NO;
Simon M
  • 2,931
  • 2
  • 22
  • 37
User-1070892
  • 929
  • 10
  • 16
4

I know this is an old question however it lacked the swift version so, in Swift 3 it is:

tableView.isUserInteractionEnabled = false;

and to turn it back on is:

tableView.isUserInteractionEnabled = true;

Just thought this might help someone if they were looking for the answer in swift 3 as I was, and ends up here.

Mark Dail
  • 501
  • 4
  • 10