0
REFeveItinerarioCell *cell = nil;
         cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        NSDictionary *itemData = [self.tableDatawithcoordinate objectAtIndex:indexPath.row];


        if(cell==nil)
        {
            NSLog(@"New Cell");

            NSArray *nib=[[NSBundle mainBundle] loadNibNamed:@"REFeveItinerarioCell" owner:self options:nil];
            cell=[nib objectAtIndex:0];

 //my code for filling tableview           
}

大家好,就像上面一样,我正在填写表格视图。但是在某些值之后,相同的值会重复。可能是什么问题?

提前致谢

4

1 回答 1

0

您应该使用 tableview 注册 nib,可能是viewDidLoad:这样的:

[self.tableView registerNib:[UINib nibWithNibName:@"REFeveItinerarioCell" bundle:nil] forCellReuseIdentifier:@"CellIdentifier"];

然后,您应该在 cellForRow 方法中执行此操作:

/**
 *  Asks the data source for a cell to insert in a particular location of the table view.
 *
 *  @param  tableView                   A table-view object requesting the cell.
 *  @param  indexPath                   An index path locating a row in tableView.
 *
 *  @return An object inheriting from UITableViewCell that the table view can use for the specified row.
 */
- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell               = [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier" forIndexPath:indexPath];

    //  do any of the configuration

    return cell;
}

某些单元格的数据相同的原因是 UITableViewCells 正在被重用。这意味着先前的单元格及其属性正在被重新用于新单元格。您应该 nil 并设置您不希望相同的任何属性。

于 2013-11-13T11:26:58.153 回答