从表视图中删除多个单元格

时间:2012-06-04 09:51:30

标签: iphone ios uitableview

我有从具有自定义单元格的数据库加载的表视图。在按钮上复选框应出现在表视图的每个单元格上。在此之后我只想从表格视图中删除选中的项目。怎么可能?

2 个答案:

答案 0 :(得分:1)

我猜你有一个数组要填充。

所以你必须删除数组中的元素 一个像这样的重载数据

[yourTableView reloadData];

答案 1 :(得分:1)

Here recording data array is a array of dictionary in which there is a key which keep track of which button is checked or which is unchecked. on clicking Delete button you can use below mentioned concept for deleting more than open array at a go :

USE THIS CONCEPT : 

    - (IBAction)deleteClicked:(id)sender 
    {
        for(int index = 0 ; index < [recordingDataArray count] ; index++)
        {
            NSMutableDictionary *item = [recordingDataArray objectAtIndex:index];
            BOOL checked = [[item objectForKey:@"checkStatus"] boolValue];
            if(checked)
            {
                [recordingDataArray removeObjectAtIndex:index];
                index--;
            }
        }
        [self.recordingTblView reloadData];
    }

THANKS & REGARDS,
GAUTAM TIWARI