いらっしゃいませ!私は午前中ずっとこれに取り組んでいましたが、バナナはありませんでした。多分あなたは洞察力を持っています!
私は標準で作業していますNSMutableArray
:
self.itemTable = [[NSMutableArray alloc]
initWithObjects:@"House.",
@"Car.",
@"Keys.", nil];
ナビゲーションバーで「編集」を押して行を削除すると、次のエラーメッセージが表示されます
キャッチされていない例外 'NSInternalInconsistencyException' が原因でアプリを終了しています。更新前のセクション (3)、そのセクションから挿入または削除された行数 (0 挿入、1 削除) のプラスまたはマイナス、およびそのセクションに移動された、またはセクションから移動された行の数 (0 移動、0 移動)アウト)。'
「削除」コマンドに次のコードを使用します。
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
行削除機能を機能させる方法についての洞察はありますか?
編集:
それを見つけた:作業中の次のコード行を配置する:
[self.itemTable removeObjectAtIndex:indexPath.row];
これにより、削除コードが作成されます。
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
[self.itemTable removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}