テーブルビューが編集モードで、ユーザーがセルを移動しているとき。現在移動中のセルのインデックスパスは何ですか?残りのセルのインデックスパスはどのように影響を受けますか?
(私は実際にこの問題を解決するためにこれを学ぼうとしています。)
どんな助けでも大歓迎です。ありがとう!
テーブルビューが編集モードで、ユーザーがセルを移動しているとき。現在移動中のセルのインデックスパスは何ですか?残りのセルのインデックスパスはどのように影響を受けますか?
(私は実際にこの問題を解決するためにこれを学ぼうとしています。)
どんな助けでも大歓迎です。ありがとう!
代理人にこの問題の面倒を見てもらいましょう。そういうわけでそれはそこにあります!– tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath:
- (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath: (NSIndexPath *)proposedDestinationIndexPath
{
if (proposedDestinationIndexPath.section != sourceIndexPath.section)
{
return sourceIndexPath;
}
return proposedDestinationIndexPath;
}
以下に示すように、tableView:moveRowAtIndexPath:toIndexPath:データソースメソッドで別のチェックを行うことを忘れないでください。宛先がソースに類似している場合は、アプリケーションロジックを実行しないでください。
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
if(sourceIndexPath == destinationIndexPath)
{
return;
}
//application logic
}