didEndEditingRowAtIndexPath with nil indexPath
2015-01-22 14:38
183 查看
在UITableViewController中,通过滑动删除按钮删除一行,首先收到Table view data source call:
在这个调用中,需要首先删除数据,再删除界面上该行:
在删除行的时候,会调用另一个Table view delegate call:
indexPath参数指向的就是刚删除的cell的位置。于是我在这里做了一些其它刷新操作。
接着,意向不到的事情发生了,UITableViewController又一次调用了Table view delegate:
此时传输的indexPath参数为——nil
我还没有在SDK中找到关于后一个调用的作用的描述,为避免重复操作,我只在这里调用了刷新操作:
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]; }
相关文章推荐
- dataWithContentsOfURL返回nil
- Editing with the geodatabase API
- When to use dequeueReusableCellWithIdentifier vs dequeueReusableCellWithIdentifier: forIndexPath
- 关于'NSConcreteMutableAttributedString initWithString:: nil value'
- IOS--错误集锦--reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
- .Cannot create an NSPersistentStoreCoordinator with a nil model
- Ruby remove nil values from array with .reject
- Lua中table.sort() 报错 attempt to compare number with nil和invalid order function for sorting
- 直接用URLWithString来拼接NSURL有时候得到的NSURL是为nil的
- iOS 运行出现:Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /Sourc
- iOS URLWithString返回为空nil的解决方案
- IOS--错误集锦--reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
- [tableView dequeueReusableCellWithIdentifier:CellIdentifier] 后面forIndexPath:indexPath参数的解释
- [[MyViewController alloc] initWithNibName:nil bundle:nil]; 搜索 Nib 文件的规则及注意事项
- *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from o
- [NSPlaceholderString initWithString:]: nil argument- 参数为空导致!
- [转] WPF – Editing Mode with Save and Cancel Capability
- Editing Null Data Values in a Cell with JavaFX 2
- stringWithFormat传参nil会怎样
- 使用AES加密的时候(encryptString:(NSString*)string withKey:(NSString*)key) 出现结果是nil