美文网首页
自定义UITableViewCell偶现点击没反应的问题

自定义UITableViewCell偶现点击没反应的问题

作者: 左方 | 来源:发表于2019-10-15 14:55 被阅读0次

自己写了XXXCell.h .m .xib
注册UITableView时,写了

[table registerNib:[UINib nibWithNibName:cellName bundle:nil] forCellReuseIdentifier:cellName];

cellForRowAtIndexPath中写了:

    XXXCell *cell = [tableView dequeueReusableCellWithIdentifier: cellIdentifier forIndexPath:indexPath];

发现问题有时候点击cell没反应;全选的时候有时会空出几行没有选到。

现在去掉

[table registerNib:[UINib nibWithNibName:cellName bundle:nil] forCellReuseIdentifier:cellName];

cellForRowAtIndexPath中改为:

    static NSString * cellIdentifier = @"XXXCell";
    XXXCell *cell = (XXXCell *)[tableView dequeueReusableCellWithIdentifier: cellIdentifier];
    if (!cell) {
        cell = [[[NSBundle mainBundle] loadNibNamed: cellIdentifier owner:self options:nil] lastObject];
    }

问题就解决了。原因未知待调查。

相关文章

网友评论

      本文标题:自定义UITableViewCell偶现点击没反应的问题

      本文链接:https://www.haomeiwen.com/subject/ztjsmctx.html