I’m trying to ignore touches for a certain subviews added to my custom UITableViewCell subclass. I set exclusiveTouch to YES for that subview but the touches still trigger the cell selection.
Is there a way to avoid that selection just when touches are in that subiew?
Thanks
I’m trying to ignore touches for a certain subviews added to my custom UITableViewCell
Share
In my experience, @Ali3n’s solution doesn’t work (i.e. using view.userInteractionEnabled = NO). When you tap on the view, the cell is still selected.
However, I’ve found that if you add a UIButton as a subview, and add your subviews to that then it does work as you’d expect – i.e. you tap on the area covered by the button and the cell is not selected.
If you use a custom style UIButton then it doesn’t look any different to a plain UIView anyway.
Here’s how I add a UISwitch to the accessoryView with a non-tappable UIButton behind it. If you miss the button and hit the background the cell is not selected.