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 }
  • 相关阅读:
    2月5号:linux运维shell
    linux命令go on
    2月6日:linux下命令与查看方式
    AHU_OJ 08
    AHU_OJ 57
    javascript学习笔记2
    javascipt学习笔记1
    javascript学习笔记4
    javascript学习笔记3
    未能加载文件或程序集“”或它的某一个依赖项。系统找不到指定的文件
  • 原文地址:https://www.cnblogs.com/hw140430/p/3703020.html
Copyright © 2011-2022 走看看