由于cell是高效复用的,每当拖动后,在cell.contentView,这些个view就会重叠,网上找了些方法,结合自己的代码,记录下来。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//这里的reuse,是cell的Identifier
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse" forIndexPath:indexPath];;
if (!cell) {
//在 cell中增加需要的内容
cell add things
}
else {
//移除原来的子视图
while ([cell.contentView.subviews lastObject] != nil) {
[(UIView*)[cell.contentView.subviews lastObject] removeFromSuperview];}
}
//在 cell中增加需要的内容
cell add things
return cell;
}