Unexpected nil index path in _shouldShowMenuForCell
Asked Answered
T

3

6

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 !!!

Tallbott answered 27/9, 2017 at 7:8 Comment(2)
Care to share some code?Cotopaxi
It isn't anything special, only VC with UItableView. Cell swiping I created using gesture recognizer implemented in subclass of UITableViewCell and works fine, problem starting when this log is showing.Tallbott
T
1

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:

Tallbott answered 29/1, 2018 at 10:56 Comment(0)
T
2

I change swiping method from gestureRecognizer to ScrollView and everything works perfect.

Tallbott answered 27/9, 2017 at 10:14 Comment(0)
S
2

If your cell is created by - [[[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil] lastObject];

AND using addSubview to display it. This problem will occur.

My solution is using "addSubview:cell.contentView" BUT NO "addSubview:cell"

Snort answered 14/12, 2017 at 9:52 Comment(1)
I did the same but not working, tableViewCell.contentView.addSubview(tableViewCell.webView) do you have any more suggestion ?Laryngeal
T
1

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:

Tallbott answered 29/1, 2018 at 10:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.