iOS – Delayed “Touch Down” event for UIButton in UITableViewCell

This is caused by the UIScrollView property delaysContentTouches.

It used to be sufficient to just set that property to NO for the UITableView itself, but that will only work for subviews of the table that are not encased in another UIScrollView.

UITableViewCells contain an internal scroll view in iOS 7 so you will need to change the value of this property on the cell level for all cells with buttons in them.

Here is what you need to do:

1.in viewDidLoad or somewhere similar once your UITableView has been initialized, put this in:

self.tableView.delaysContentTouches = NO;

2.for iOS 7 support, in the initialization method for your UITableViewCell (initWithStyle:reuseIdentifier: or initWithCoder: for NIBs), put this in at the end:

for (UIView *currentView in self.subviews)
{
    if([currentView isKindOfClass:[UIScrollView class]])
    {
        ((UIScrollView *)currentView).delaysContentTouches = NO;
        break;
    }
}

This is unfortunately not a 100% permanent solution as Apple can change the view hierarchy inside cells again in the future (perhaps moving the scroll view another layer down or something which would require you to nest another loop in there), but until they surface the class or at least the property to developers somehow, this is the best we’ve got.

Leave a Comment