-1

我创建了一个表格视图。我的每一行都有一个删除按钮。现在,当我删除第一行时,最后一行将再次添加到表格视图中。

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:   (NSIndexPath *)indexPath
{
    if(currentHTMLElement==@"1") {
        static NSString *CellIdentifier=@"Cell";
        UITableViewCell* cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        if(cell == nil) {
            cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault    reuseIdentifier:CellIdentifier]autorelease];
        }

        NSMutableDictionary *d = (NSMutableDictionary *) [arr objectAtIndex:indexPath.row];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        retun cell;
    }
}

我在每一行都有更多的标签。另外,我重新加载表格视图。

4

2 回答 2

0

确保以这种方式删除它:

[self.tableView beginUpdates];
//delete item form you array (arr)
//delete row from tableView
[self.tableView reloadData];
[self.tableView endUpdates];
于 2013-02-22T12:12:21.037 回答
0

可以替换currentHTMLElement==@"1"[currentHTMLElement isEqualToString:@"1"]

于 2013-02-22T11:48:36.263 回答