2013-03-12 129 views
0

我有一個表視圖與所有必需的數據源和委託方法。無法移動表格視圖單元格時刪除

當我滑動單元格時正在運行,刪除按鈕出現,但出現在單元格內容中。 單元格不移位。

我預計移動細胞的功能出現在下面的代碼,但它不會

- (void)setEditing:(BOOL)editing animated:(BOOL)animated 
{ 
    [super setEditing:editing animated:animated]; 
    [self.tableView setEditing:editing animated:animated]; 
} 

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if(indexPath.row) 
     return YES; 
    else 
     return NO; 
} 

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    return UITableViewCellEditingStyleDelete; 
} 


- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (editingStyle == UITableViewCellEditingStyleDelete) 
    { 

     [[NoteManager sharedManager] removeNoteAtIndex:indexPath.row]; 
     [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
    } 
} 

請幫我解決這個簡單的問題 快速的幫助是appriciated ..

回答

0

將子視圖添加到單元格時,請確保將它們添加到單元格的contentView,而不是單元格。

[cell.contentView addSubview:someSubview]; 

contentView的框架將根據需要進行調整,包括刪除按鈕在內的各種單元裝飾。

相關問題