我有一个看起来像这样的代码片段:
[tableView beginUpdates];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[array indexOfObject:[array objectAtIndex:indexPath.row]]] withRowAnimation:UITableViewRowAnimationLeft];
[tableView endUpdates];
[tableView reloadData];
它在用户单击附件时执行。第一部分只是为了提供流畅的动画,并不重要,因为 tableView 会在几毫秒后重新加载,但正如我所说,它是为了提供动画。
它应该将选定对象从其当前 indexPath 移动到同一 indexPath 的数组中的值。
显然,这段代码不起作用,所以我只想知道可以做些什么来修复它?
PS:编译时我也会收到警告。通常的“'arrayWithObject:' 的传递参数 1 使指针从整数而不进行强制转换......”(第 3 行)
结束了这个片段:
[tableView beginUpdates];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:[array indexOfObject:[arraySubFarts objectAtIndex:indexPath.row]] inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
[tableView endUpdates];
[tableView reloadData];