避免UITableViewCell重叠的解决方法
在IOS开发的时候经常会用到UITableView,而当TableView进行拖动的时候经常会导致Cell的重叠,解决方法,
1
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"ToneBoxMusicStyleViewCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"ToneBoxMusicStyleViewCell" owner:self options:nil]; if ([nib count] > 0) { cell = self.styleViewCell; } }else{ for (UIView *subView in cell.contentView.subviews) { [subView removeFromSuperview]; } } return cell;}
?
?
2
//构建tableView-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell= [tableView dequeueReusableCellWithIdentifier:@"TodoViewController"]; cell.tag = 1; if(!cell){ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"TodoViewController"]autorelease]; }else{ while ([cell.contentView.subviews lastObject] != nil) { [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview]; } }
?