UICollectionView drag finger over cells to select them

后端 未结 2 1619
庸人自扰
庸人自扰 2020-12-28 12:04

Using UICollectionView, is it possible to select multiple cells by dragging your finger over a few of them? E.g., if you drag your finger over a row of 6, and d

2条回答
  •  梦毁少年i
    2020-12-28 12:22

    You could use UIPanGestureRecognizer. And based on the location of the pan events, tracking what cells are passed through. When the gesture ends, you would have an array of selected cells.

    Make sure that cancelsTouchesInView is set to NO. You'll need to set the delegate with gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: and gestureRecognizerShouldBegin implemented to make sure the CollectionView can still scroll

提交回复
热议问题