2011-10-06 23 views
3

我想知道是否有反正停止「清除」按鈕出現在特定的uitableviewcell並讓它出現在另一個?tableview:commitEditingStyle:forRowAtIndexPath如何停止在某些單元格上顯示刪除按鈕

我已成立了,在它有一個按鈕的是定製的UITableView細胞,我現在用的是

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

方法。我想知道,如果你能停止對幾種一個apprears按鈕uitableviewcells當用戶滑動刪除?

- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    return @"Clear"; 
} 

// Override to support editing the table view. 
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (indexPath.section == 0) 
    { 
     //cell fade - notifies the user that they are edited their cell 
     NSArray *rowArray = [NSArray arrayWithObject:indexPath]; 
     [self.tableView reloadRowsAtIndexPaths:rowArray withRowAnimation:UITableViewRowAnimationFade]; 

     if (indexPath.row == 0) 
     { 

      manufactureSearchObjectString = @"empty"; 
      [self.tableView reloadData]; //reloads the tabel with new value 
      manufactureResultIndexPath = nil; //removes tick from subview 

     } 
     else if (indexPath.row == 1) 
     { 

     } 
     else if (indexPath.row == 2) 
     { 

     } 
     else if (indexPath.row == 3) 
     { 
      keyTypeSearchObjectString = @"empty"; 
      [self.tableView reloadData]; //reloads the tabel with new value 
      keyTypeResultIndexPath = nil; //removes tick from subview 

     } 
    } 
    else if (indexPath.section == 1) 
    { 
     if (indexPath == 0) 
     { 
      //can I stop the "clear" button from showing in here? 
     } 
    } 
} 

要多一點具體的我想阻止這種情況的發生以下方法 enter image description here

回答

6

使用

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
      if (indexPath.section == 1) 
      { 
       if (indexPath.row == 0) 
       { 
       return NO;// you can stop the "clear" button from showing in here? 
       } 
       else 
       return YES; 
      } 
      else 
      return YES; 


    } 
+0

涼爽,完美的工作!非常感謝您的幫助! :) –

相關問題