Я установил панель навигации с помощью кнопки добавления, которая добавляет данные в мое табличное представление.Я также добавил эту строку self.navigationItem.leftBarButtonItem = self.editButtonItem;
, чтобы создать кнопку редактирования.Просматривая метод, я замечаю метод - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
.Поэтому я внес изменения ниже, но мое приложение зависает.Как правильно удалить данные из моей таблицы?
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
**[myArray removeObjectAtIndex:[indexPath row]];
[self.tableView reloadData];**
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}
}