Search code examples
iosswiftuitableviewuiswipegesturerecognizer

Unexpected nil index path in _shouldShowMenuForCell


Does anyone know what is going on with this problem? My cell stop swiping because of this.

[Assert] Unexpected nil index path in _shouldShowMenuForCell:, this should never happen. Cell ; baseClass = UITableViewCell; frame = (0 97.5; 375 130); alpha = 0; hidden = YES; autoresize = W; gestureRecognizers = ; layer = >

Help !!!


Solution

  • I already found solution even with creating swipe cell using gesture recognizer, in my case the problem ("Unexpected nil index path in _shouldShowMenuForCell:, this should never happen. ") was appearing because of this function:

    override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
            for subview in self.subviews.reversed() {
                if subview.frame.contains(point) {
                    return subview
                }
            }
    
            return super.hitTest(point, with: event)
    }
    

    tip: Working solution of: Capturing touches on a subview outside the frame of its superview using hitTest:withEvent: