-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

と置き換えることができcurrentHTMLElement==@"1"ます[currentHTMLElement isEqualToString:@"1"]

于 2013-02-22T11:48:36.263 に答える
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 に答える