itgiawa
itgiawa

Reputation: 1616

disable touch interaction in UITableView

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!

Upvotes: 22

Views: 22366

Answers (2)

Mark Dail
Mark Dail

Reputation: 500

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.

Upvotes: 4

User-1070892
User-1070892

Reputation: 929

Try this... After clicking on cell set

tableView.userInteractionEnabled = NO;

Upvotes: 42

Related Questions