美文网首页
解决UITableView重叠问题

解决UITableView重叠问题

作者: 弥灬zero | 来源:发表于2020-04-14 09:53 被阅读0次

UITableView遇到重叠问题

解决方案:

  1. 定义一个cell的标识,注意用static修饰
    static NSString *ID = @"initTheAccountInfoWithCell";
    
  2. 从缓存池中取出cell,如果缓存池中没有cell
    QFInitTheAccountInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell ==nil) {
       cell = [[self alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }else{
       //删除并进行重新分配, 解决cell重叠问题
       while([cell.contentView.subviewslastObject] !=nil) {
          [(UIView*)[cell.contentView.subviews lastObject] removeFromSuperview];
       }
    }
    

相关文章

网友评论

      本文标题:解决UITableView重叠问题

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