6

I have a UITableView embedded inside of a UICollectionView, the collection view scrolls horizontally so if i try a 'swipe to delete' on one of the table view rows which is inside of a collection view cell, it obviously just scrolls the collection view. Was wondering if there is a work around so that it could detect the swipe on the uitableview part of the collection view cell instead of swiping the uicollection view itself? The UITableView only takes up about a quarter of the collection view cell. I'm using a UIViewController. And i also have paging enabled on my collection view.

Luke97
  • 529
  • 3
  • 11
  • 27

3 Answers3

1

You may use as workaround implementing the hit test like described here for make that the UICollectionView don't get the gestures events when scrolling inside the cell's frame

but IMHO you should not try to break the default behavior and should look to change your UI...

Macistador
  • 854
  • 12
  • 23
1

Try one of the two options:

You just have to figure how you can identify/retrieve both of the gesture recognizers (hint: browse the gestureRecognizers property to find some PanGestureRecognizers)


And you should definitely refine that clunky design.

Crazyrems
  • 2,551
  • 22
  • 40
-1

You can try adding a UISwipeGestureRecognizer to each collection cell and then in it's target action check (gestureRecognizer.state == UIGestureRecognizerStateEnded) and add your code.

Anushk
  • 482
  • 4
  • 20