首页 > 其他 > 详细

UITableViewCell 左滑删除

时间:2015-11-19 16:17:27      阅读:231      评论: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)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!