首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

避免UITableViewCell重叠的解决办法

2013-07-04 
避免UITableViewCell重叠的解决方法在IOS开发的时候经常会用到UITableView,而当TableView进行拖动的时候经

避免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];        }    }

?

热点排行