アプリにいくつかの UITableView があり、スワイプして削除すると、それらすべてで正常に機能します。問題は、空のセル (下部) をスワイプしようとすると、アプリが次のようにクラッシュすることです。
*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-1914.84/UITableView.m:833
2012-03-24 16:20:03.158 [22339:707] Exception - attempt to delete row 3 from section 0 which only contains 3 rows before the update - attempt to delete row 3 from section 0 which only contains 3 rows before the update
cellForRowAtIndexPath, commitEditingStyle
クラッシュの前に呼び出されることも呼び出されることもありませんeditingStyleForRowAtIndexPath
。私のメソッドが呼び出される前にクラッシュが発生するようです。
参考までに、私はこれを持っていますeditingStyleForRowAtIndexPath
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
if ((indexPath.row == self.insertIndex && indexPath.section == [self.sections count] -1) || (indexPath.row == 0 && [sections count]==0)) { // last row of section, or only row of only section
return UITableViewCellEditingStyleInsert;
} else {
return UITableViewCellEditingStyleDelete;
}
}
更新:テーブルビューがスクロールするとアプリが事実上使用できなくなるため、これは実際には大きな問題です。