AQGridView icon indicating copy to clipboard operation
AQGridView copied to clipboard

On cell reordering

Open evadne opened this issue 14 years ago • 4 comments

Do you think it’s a good idea to move code from the Springboard example back to the grid view itself?

evadne avatar Mar 06 '11 14:03 evadne

While being a very helpful starting point for this sort of functionality, I've found the reordering logic in the Springboard example did not need my reordering needs

For example, I'm currently struggling to get reordering, addition and deletion working with items that are sorted by position. In this case, reordering items needs to recalculate and update the sort property the underlying model objects in the grid when the gesture has ended.

If this were moved into the grid view, it would either need to be made more generic to handle a reasonably wide range of use cases or I'd need to subclass AQGrid view.

lightandshadow68 avatar May 22 '11 22:05 lightandshadow68

As an update, I’ve implemented reordering, insertion, updating and deletion all from the calling class instead of in the grid view itself. Sorting is handled by the data source which respects a phantom cell.

evadne avatar May 22 '11 22:05 evadne

Are you referring to AQDataSource or your data source class?

Currently, I'm using AQGridCell with an instance of NSFetchedResultsController.

I've managed to get reordering working. However, attempting to add and remove cells the grid is either removing duplicate cells with the same displayIndex, which leaves blank cells, or it's throwing a inconstancy exception. This is likely due to the fetched results controller calling add / remove / update calls while tracking changes to the fetched data.

Making AQDataSource aware of the phantom cell sounds like a good solution.

lightandshadow68 avatar May 22 '11 22:05 lightandshadow68

Custom data source.

Just making sure that adding / removing cells do not happen at the same time that reordering is taking place should be adequate.

evadne avatar May 22 '11 22:05 evadne