0

テーブルビューが編集モードで、ユーザーがセルを移動しているとき。現在移動中のセルのインデックスパスは何ですか?残りのセルのインデックスパスはどのように影響を受けますか?

(私は実際にこの問題を解決するためにこれを学ぼうとしています。)

どんな助けでも大歓迎です。ありがとう!

4

2 に答える 2

0

代理人にこの問題の面倒を見てもらいましょう。そういうわけでそれはそこにあります!– tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath:

于 2012-10-04T07:51:45.937 に答える
0
- (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
}
于 2012-10-04T08:18:41.140 に答える