iOS14 自定制tableViewCell不能点击

更新iOS14之后,tableView不能点击,自定制tableViewCell不能点击
解决方法

需要将View [self.contentView addSubview] 而不是 [self addSubview]

自定制cell中iOS14之前代码

_headImage = [[UIImageView alloc] initWithFrame:CGRectMake(17.5, 17, 17, 17)];
[self addSubview:_headImage];
    _titleLabel = [[UIFactory shareInstace] setLabel:CGRectMake(43, 15, 200, 22.5) text:@"" font:[UIFont systemFontOfSize:16] textColor:rgba(0, 0, 0, 0.85)];
[self addSubview:_titleLabel];

_backLabel = [[UIFactory shareInstace] setLabel:CGRectMake(0, 13.5, SCREEN_WIDTH-24, 22.5) text:@"退出登录" font:[UIFont systemFontOfSize:16] textColor:rgba(0, 0, 0, 0.85)];
_backLabel.textAlignment = NSTextAlignmentCenter;
_backLabel.hidden = YES;
[self addSubview:_backLabel];

_rightImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"右"]];
_rightImageView.frame = CGRectMake(SCREEN_WIDTH-24-16-16, 21.5, 16, 16);
[self addSubview:_rightImageView];

_lineView = [[UIFactory shareInstace] setLineView:CGRectMake(43, 52.5, SCREEN_WIDTH-24-43, 0.5) color:rgba(0, 0, 0, 0.1)];
[self addSubview:_lineView];

自定制cell中iOS14之后代码

_headImage = [[UIImageView alloc] initWithFrame:CGRectMake(17.5, 17, 17, 17)];
    [self.contentView addSubview:_headImage];
    
        _titleLabel = [[UIFactory shareInstace] setLabel:CGRectMake(43, 15, 200, 22.5) text:@"" font:[UIFont systemFontOfSize:16] textColor:rgba(0, 0, 0, 0.85)];
[self.contentView addSubview:_titleLabel];

_backLabel = [[UIFactory shareInstace] setLabel:CGRectMake(0, 13.5, SCREEN_WIDTH-24, 22.5) text:@"退出登录" font:[UIFont systemFontOfSize:16] textColor:rgba(0, 0, 0, 0.85)];
_backLabel.textAlignment = NSTextAlignmentCenter;
_backLabel.hidden = YES;
[self.contentView addSubview:_backLabel];

_rightImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"右"]];
_rightImageView.frame = CGRectMake(SCREEN_WIDTH-24-16-16, 21.5, 16, 16);
[self.contentView addSubview:_rightImageView];

_lineView = [[UIFactory shareInstace] setLineView:CGRectMake(43, 52.5, SCREEN_WIDTH-24-43, 0.5) color:rgba(0, 0, 0, 0.1)];
[self.contentView addSubview:_lineView];

你可能感兴趣的:(iOS14 自定制tableViewCell不能点击)