Weird iOS bug with UITableViewCell and userInteractionEnabled

后端 未结 2 1285
天涯浪人
天涯浪人 2020-12-19 02:53

I just noticed something very strange with the UITableViewCell class on iOS and the userInteractionEnabled property.

It appears that if userInteractionEnabled is set

相关标签:
2条回答
  • 2020-12-19 03:19

    I found that if I put cell.textLabel.textColor = [UIColor blackColor]; right before cell.userInteractionEnabled = NO; , it seems to fix the problem. This is how it is working on iOS 6.0.1

    cell.textLabel.textColor = [UIColor blackColor];
    cell.userInteractionEnabled = NO;
    
    0 讨论(0)
  • 2020-12-19 03:33

    I think I found a more convenient workaround for this problem (which I consider to be a bug):

    Set the enabled property on textLabel and detailTextLabel manually like this:

    cell.userInteractionEnabled = (indexPath.row % 2) == 0;
    cell.textLabel.enabled = cell.isUserInteractionEnabled;
    cell.detailTextLabel.enabled = cell.isUserInteractionEnabled;
    

    This led me to the answer: https://stackoverflow.com/a/13327632/921573

    0 讨论(0)
提交回复
热议问题