ITeye博客

uitableview cell 数据重复

修博龙泉 · 2012-11-26 10:58 · ios开发学习相关 · 移动开发 · Markdown


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];
    if (cell == nil) {
        cell = [[[uitableviewcell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }else{
        while ([cell.contentview.subviews lastobject] != nil) {
            [(uiview*)[cell.contentview.subviews lastobject] removeFromSuperview];  //删除并进行重新分配
        }
    }


  NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];
    if (cell == nil) {
        cell = [[uitableviewcell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    for (UIView *subView in cell.contentView.subviews) {
        [subview removefromsuperview];
    }


评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。