Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Crash when drag card #22

@RoshaniDias

Description

@RoshaniDias

Hello,
When I keep dragging the card here and there without moving it down, app crash in this line
collectionView?.bringSubview(toFront: cell!)

in this method

//Define what card should we drag
    fileprivate func findDraggingCellByCoordinate(_ touchCoordinate: CGPoint) {
        if let indexPath = collectionView?.indexPathForItem(at: touchCoordinate) {
            if indexPath.item >= index {
                //top stack
                draggedCellPath = IndexPath(item: index, section: 0)
                initialCellCenter = collectionView?.cellForItem(at: draggedCellPath!)?.center
            } else {
                //bottomStack
                if (index > 0 ) {
                    draggedCellPath = IndexPath(item: index - 1, section: 0)
                }
                initialCellCenter = collectionView?.cellForItem(at: draggedCellPath!)?.center
            }
            
            //workaround for fix issue with zIndex
            let cell = collectionView!.cellForItem(at: draggedCellPath!)
            collectionView?.bringSubview(toFront: cell!)
            
        }
    }

How to overcome this issue. Please help me.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions