didEndEditingRowAtIndexPath with nil indexPath

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

tableView:commitEditingStyle:forRowAtIndexPath

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

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

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

tableView:didEndEditingRowAtIndexPath:

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

 

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

tableView:didEndEditingRowAtIndexPath:

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

我尚未在SDK中找到关于后一个调用的做用的描述,为避免重复操做,我只在这里调用了刷新操做:it

if (indexPath == nil) {
    NSTimer * timer = [NSTimer timerWithTimeInterval:.5f target:self selector:@selector(reload:) userInfo:nil repeats:NO];
    [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
}
相关文章
相关标签/搜索