1. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { 
  2.     return YES; 
  3. } 
  4.   
  5. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 
  6.   
  7.      if (editingStyle == UITableViewCellEditingStyleDelete) { 
  8.          [dataArray removeObjectAtIndex:indexPath.row]; 
  9.          // Delete the row from the data source. 
  10.          [testTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
  11.           
  12.      }    
  13.      else if (editingStyle == UITableViewCellEditingStyleInsert) { 
  14.      // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. 
  15.      }  
  16.  } 
 按理说故事讲到这里也就讲完了.但是笔者想延伸一下.注意看图二划动以后的"Delete",你有没有想把这个东东改掉的冲动呢?比如改成:下载?其实很简单,其实下面这个代理方法:
 
  1. - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{ 
  2.         return @"下载"; 
  3. } 

相关文章:

  • 2021-11-22
  • 2021-11-19
  • 2021-06-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-04
  • 2021-07-28
  • 2022-12-23
相关资源
相似解决方案