我在tableviewdidSelectRow中有这段代码:
[tableView beginUpdates];
[tableView insertSections:[NSIndexSet indexSetWithIndex:tableView.numberOfSections] withRowAnimation:UITableViewRowAnimationFade];
[tableView moveRowAtIndexPath:indexPath toIndexPath:[NSIndexPath indexPathForRow:0 inSection:tableView.numberOfSections ]];
[tableView endUpdates];
在endUpdates之后我崩溃了:
无法将行移动到新插入的部分
我的错误在哪里?如何使用动画创建新的部分并将行移动到它?
答案 0 :(得分:0)
[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];