У меня есть UITableView с перетаскиваемыми строками, и я могу добавлять/удалять элементы. Источником данных является NSMutableArray.
Теперь, если я перемещаю строку с помощью "Добавить новую функциональность", приложение выходит из строя, потому что dataSource меньше, поскольку такая строка еще не добавлена.
Итак, я изменил этот код:
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row >= [dataList count]) return NO;
return YES;
}
И теперь я больше не могу двигаться. Однако я могу по-прежнему перемещать другие строки после такой строки и, следовательно, сбой кода.
Как я могу это решить? Есть ли способ отключить перетаскивание "в" определенных строк, а не только из?
спасибо