2011-10-06 55 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

凉爽,完美的工作!非常感谢您的帮助! :) –

相关问题