今天这个东西是之前遇到没有解决的问题,直接上代码
TTDynamicsCommentCell *commentCell=[tableView dequeueReusableCellWithIdentifier:@"comment"];
if (!commentCell) {
commentCell =[[TTDynamicsCommentCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"comment"];
}else{
while ([commentCell.contentView.subviews lastObject] != nil) {
[(UIView*)[commentCell.contentView.subviews lastObject] removeFromSuperview]; //删除并进行重新分配
}
//这块红色的代码就是解决问题的关键,每次滑动tableview的时候就会删除cell,然后在下面 重新调用这个方法加载数据 [commentCell setCellProperty:cellDic];,完美的解决了cell的内容会跑到下一个cell里面
}
//
NSDictionary *cellDic=self.commentArr[indexPath.row];
[commentCell setCellProperty:cellDic];
return commentCell;