• IOS7 UITableView一行滑动删除后 被删除行的下一行的点击事件将被忽略解决办法


    - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        returnUITableViewCellEditingStyleDelete;
    }
    
    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if (editingStyle == UITableViewCellEditingStyleDelete)
        {
            [self.items removeObjectAtIndex:indexPath.row];
            [tableView reloadData];
        }
    }
    
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        NSLog(@"Row %@ tapped.", self.items[indexPath.row]);
    }
    
    在ios6环境下,上段代码运行正常。但是在ios7环境下,我做了如下操作:当tableview中的一行被删除并更新tablview后,被删除行的下一行的点击事件将被忽略,导致点击该行无反应(双击才有反应)。很奇怪是不是,下面将解释原因。
    当tableview中的某行被选中删除后,tableview将处于编辑(editing)状态,所以你需要将tableview中的状态更换成选择(selection)模式,更改代码如下:
    
    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
    {
      if (editingStyle == UITableViewCellEditingStyleDelete)
      {
        [self.items removeObjectAtIndex:indexPath.row];
    
        // Turn off editing state here
        tableView.editing = NO;
    
    
        [tableView reloadData];
      }
    }
    

      

  • 相关阅读:
    pandas笔记
    MongoDB分片集群技术
    MongoDB基本操作
    linux MongoDB安装配置
    MongoDB入门
    introJs用法及在webkit内核浏览器的一个报错
    日常ie兼容问题(持续整理)
    浅谈connect,withRouter,history,useState,useEffect
    node环境配置
    小程序之签到
  • 原文地址:https://www.cnblogs.com/joesen/p/3701271.html
Copyright © 2020-2023  润新知