zoukankan      html  css  js  c++  java
  • 两种局部刷新UITableView的方法的使用条件

     1 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
     2 
     3   //1.取消选中这一行
     4 
     5   [tableView deselectRowAtIndexPath:indexPath animated:YES];
     6 
     7   //2.获取当前选中的数据
     8 
     9   Shop *shop = _shops[indexPath.row];
    10 
    11   //3.控制当前cell是否被选中
    12 
    13   if( [_deleteShops containsObject:shop] ){
    14 
    15     //如果之前已选中,现在取消选中
    16 
    17     [_deleteShops removeObject:shop];
    18 
    19   }else{
    20 
    21     //如果之前已取消选中,则现在选中
    22 
    23     [_deleteShops addObject:shop];
    24 
    25   }
    26 
    27   //4.刷新表格(1.此局部刷新方法的使用条件:在tableView总数量不变的情况下,才能用它进行局部刷新)
    28 
    29   [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationMiddle];
    30 
    31   //(2.此局部刷新方法的使用条件:调用此方法删除多少行数据,tableView也要删除相同数量的数据)
    32 
    33   [tableView deleteRowsAtIndexPaths:[indexPath] withRowAnimation:UITableViewRowAnimationTop];
    34 
    35 }
  • 相关阅读:
    设计模式之策略模式、观察者模式浅析
    axis2_1.6.2之构建web端和客户端
    EJB3之查询
    qpid之简单实例
    ant1.9.4之编译、打包、发布、清理
    四数之和
    电话号码的字母的组合
    最接近的三数之和
    三数之和
    最长公共前缀
  • 原文地址:https://www.cnblogs.com/hw140430/p/3703020.html
Copyright © 2011-2022 走看看