Here is the simplest and most elegant solution that I can come up with.
I believe you should have a CustomCell that contains an IBOutlet for ImageView on the left. You can use the hitTest method to solve your problem :)
In your CustomCell, you can assume that this is the MyTestCell class, write this,
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { if self.myImageView.frame.contains(point) { return nil } return super.hitTest(point, with: event) }
Where myImageView is the IBOulet imageView on the left side of your cell :)
All I do is check where the user clicked, if the touch point is inside the frame of the imageView cells, you return zero as a view. When you return zero, the events stop propagating to the parent views and finally never reach the cell, so didSelectRowAtIndexPath never called,
On the other hand, you have to pass the touch to the next view, and you do it simply by calling the same method on your super iOS, in the end, it will track it back to the cell and didSelectRowAtIndexPath triggers
Hope this helps :)
source share