码迷,mamicode.com
首页 > 其他好文 > 详细

UITableViewCell 左滑删除

时间:2015-11-19 16:17:54      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:

  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. } 

UITableViewCell 左滑删除

标签:

原文地址:http://www.cnblogs.com/CodingMann/p/4977905.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!