Crashing while trying to move UITableView rows

后端 未结 7 806
北恋
北恋 2021-01-06 01:13

I\'ve got some rather complicated rules for moving rows around in a UITableView. There are an undefined number of sections and rows per section, and based on v

7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-06 02:03

    Are you updating your data model for the table in targetIndexPathForMoveFromRowAtIndexPath

    Or in the DataSource delegate method: tableView:moveRowAtIndexPath:toIndexPath: ?

    Taken from the Table View Programming Guide for iPhone OS, under reordering table cells:

    The table view sends tableView:moveRowAtIndexPath:toIndexPath: to its data source (if it implements the method). In this method the data source updates the data-model array that is the source of items for the table view, moving the item to a different location in the array.

    And for the delegate method, it is written:

    Every time the dragged row is over a destination, the table view sends tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath: to its delegate (if it implements the method). In this method the delegate may reject the current destination for the dragged row and specify an alternative one.

    tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath: is for determining whether a relocation is allowed, but actual changes to your data model should take place in tableView:moveRowAtIndexPath:toIndexPath:

    Perhaps this is what you're doing, but I can't tell just from the info you provided.

提交回复
热议问题