zoukankan      html  css  js  c++  java
  • didEndEditingRowAtIndexPath with nil indexPath

    在UITableViewController中,通过滑动删除按钮删除一行,首先收到Table view data source call:

    tableView:commitEditingStyle:forRowAtIndexPath

    在这个调用中,需要首先删除数据,再删除界面上该行:

    NSMutableArray * mutable = [self.options mutableCopy];
    [mutable removeObjectAtIndex:indexPath.row];
    self.options = mutable;
            
    [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];

    在删除行的时候,会调用另一个Table view delegate call:

    tableView:didEndEditingRowAtIndexPath:

    indexPath参数指向的就是刚删除的cell的位置。于是我在这里做了一些其它刷新操作。

    接着,意向不到的事情发生了,UITableViewController又一次调用了Table view delegate:

    tableView:didEndEditingRowAtIndexPath:

    此时传输的indexPath参数为——nil

    我还没有在SDK中找到关于后一个调用的作用的描述,为避免重复操作,我只在这里调用了刷新操作:

    if (indexPath == nil) {
        NSTimer * timer = [NSTimer timerWithTimeInterval:.5f target:self selector:@selector(reload:) userInfo:nil repeats:NO];
        [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
    }
  • 相关阅读:
    Post返回json值
    调用接口并获取放回json值
    c# 获取IP
    sqlserver2008不允许保存更改
    判断客户端是否是手机或者PC
    3.docker tomcat集群
    1.docker 安装
    Maven profiles 多环境配置
    MySQL 定时任务
    MyBatis 三剑客
  • 原文地址:https://www.cnblogs.com/tara/p/4241618.html
Copyright © 2011-2022 走看看