2012-04-24 117 views
1

在我的一個ViewControllers中,我添加了一個tableview作爲子視圖。無法刪除自定義表格視圖單元格

在這個tableView中我實現了自定義表格視圖單元格。

因此,當我們按下刪除按鈕時,如何從tableView中刪除自定義Table View Cell。

誰能幫我..

回答

1

試試這個,

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (editingStyle == UITableViewCellEditingStyleDelete) 
    { 
     [tableView beginUpdates]; 
     [self.itemTable removeObjectAtIndex:indexPath.row]; 

     [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
     [tableView endUpdates]; 
}