我在tableviewdidSelectRow中有以下代码:
[tableView beginUpdates];
[tableView insertSections:[NSIndexSet indexSetWithIndex:tableView.numberOfSections] withRowAnimation:UITableViewRowAnimationFade];
[tableView moveRowAtIndexPath:indexPath toIndexPath:[NSIndexPath indexPathForRow:0 inSection:tableView.numberOfSections ]];
[tableView endUpdates];
在endUpdates之后,我崩溃了:
无法将行移到新插入的节中
我的错误在哪里?如何使用动画创建新节并将行移动到该节?
最佳答案
对于下一代来说,迟到总比不到好,我的解决方案是使用deleteRow + insertRow而不是moveRow ...,如下代码:
[self.tableView beginUpdates];
[self.tableView insertSections:[NSIndexSet indexSetWithIndex:newSectionNum]
withRowAnimation:UITableViewRowAnimationNone];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:oldIndexPath]
withRowAnimation:UITableViewRowAnimationNone];
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]
withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
关于ios - 如何使用动画创建新节并将行移动到该节,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26277633/