zoukankan      html  css  js  c++  java
  • tableView 删除一行后下一行点击事件被忽略

    【转】
    - (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]; } }
  • 相关阅读:
    线程池示例(摘抄)
    Visual Studio 相关
    Linq 内连接和外连接(转载)
    asp.net mvc4 简单使用Autofac依赖注入小结
    jquery加载解析XML文件
    权限验证AuthorizeAttribute
    常用SQL Server规范集锦及优化
    linq to datatable 和lambda查询datatable
    ASP.NET 大文件下载的实现思路及代码
    分页存储过程
  • 原文地址:https://www.cnblogs.com/wuwangchuxin/p/3701360.html
Copyright © 2011-2022 走看看