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.
Try one of the two options:
require(toFail otherGestureRecognizer: UIGestureRecognizer)
. Add the swipe gestures with this method to the collection view pan gesture when you create (or populate) the cells.shouldRequireFailure(of: otherGestureRecognizer)
. Subclass UICollectionView
and override this method to return true when otherGestureRecognizer
is actually a swipe to delete row gesture.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.
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With