Objective c tableview单元格中的数据重叠

Objective c tableview单元格中的数据重叠,objective-c,xcode,Objective C,Xcode,我正在解析json数据并将其分配到我的table view单元格中。其中tableview单元格的第一行中。我正在分配静态数据(绿色文本)。如果我滚动我的tableview,则在第一个table view单元格中分配的数据在我的第六个和第七个tableview单元格中重叠。下面是屏幕截图和代码。你们能帮我解决这个问题吗 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPat

我正在解析json数据并将其分配到我的table view单元格中。其中tableview单元格的第一行中。我正在分配静态数据(绿色文本)。如果我滚动我的tableview,则在第一个table view单元格中分配的数据在我的第六个和第七个tableview单元格中重叠。下面是屏幕截图和代码。你们能帮我解决这个问题吗

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

static NSString *CellIdentifier = @"Cell";
   UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];

}
if(indexPath.row == 0)
{

   cell.textLabel.text=@"Pollenprognosen";
    cell.textLabel.textColor=[UIColor greenColor];
    cell.detailTextLabel.text=@"se dagens pollenprognos";
    cell.detailTextLabel.font=[UIFont systemFontOfSize:([UIFont systemFontSize]-2)];

    return cell;
}
else
{
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text=[story objectAtIndex:indexPath.row];
    return cell;
}
}

我想这是因为电池被重复使用了。请尝试以下代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {

    static NSString *CellIdentifier = @"Cell";
       UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];

    }
    if(indexPath.row == 0)
    {

       cell.textLabel.text=@"Pollenprognosen";
        cell.textLabel.textColor=[UIColor greenColor];
        cell.detailTextLabel.text=@"se dagens pollenprognos";
        cell.detailTextLabel.font=[UIFont systemFontOfSize:([UIFont systemFontSize]-2)];
cell.accessoryType=UITableViewCellAccessoryNone;
        return cell;
    }
    else
    {

    cell.textLabel.text=[story objectAtIndex:indexPath.row];
cell.textLabel.textColor=[UIColor blackColor];
cell.detailTextLabel.text=nil;
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        return cell;

    }
    }

我想这是因为电池被重复使用了。请尝试以下代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {

    static NSString *CellIdentifier = @"Cell";
       UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];

    }
    if(indexPath.row == 0)
    {

       cell.textLabel.text=@"Pollenprognosen";
        cell.textLabel.textColor=[UIColor greenColor];
        cell.detailTextLabel.text=@"se dagens pollenprognos";
        cell.detailTextLabel.font=[UIFont systemFontOfSize:([UIFont systemFontSize]-2)];
cell.accessoryType=UITableViewCellAccessoryNone;
        return cell;
    }
    else
    {

    cell.textLabel.text=[story objectAtIndex:indexPath.row];
cell.textLabel.textColor=[UIColor blackColor];
cell.detailTextLabel.text=nil;
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        return cell;

    }
    }

只需按如下方式制作
else
部分

else
{
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text=[NSString stringWithFormat:@"Cell %d",indexPath.row];

    cell.textLabel.textColor=[UIColor blackColor];
    cell.detailTextLabel.text=@"";

    return cell;
}

只需按如下方式制作
else
部分

else
{
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text=[NSString stringWithFormat:@"Cell %d",indexPath.row];

    cell.textLabel.textColor=[UIColor blackColor];
    cell.detailTextLabel.text=@"";

    return cell;
}

没问题,很高兴帮助一个家伙所以:呃,老兄,我面临着同样的重叠问题。但这次是关于图像。我把它作为一个单独的问题贴了出来,你能帮我解决吗?没问题,很高兴帮助一个家伙所以:呃,老兄,我面临着同样的重叠问题。但是这次是关于图像。我把它作为一个单独的问题贴了出来,你能帮我解决吗