nullforlife nullforlife - 1 month ago 24
iOS Question

Disable 3D touch for UIButton in UITableViewCell

I have a

UITableView
with customized
UITableViewCells
. In the cells I have a
UIButton
which I don't want to be trigged by the 3D touch event for the cell.

I want it to work in a similar manner as in Apples messages app, if you take a look there it works in the way that if you press the thumbnail for the message sender image (or initials) you get a different peek & pop from when you press the whole cell. Only difference is that I want to completely ignore the peek & pop for my button. Anyone out there that knows a good solution to this?

Thank you in advance.

Answer

I solved this by adding a UIButton that covered the whole UITableViewCell and then for the UIButton I did not want to be triggered I created a separate UIView with clear background that I laid on top of the 3D touch triggered UIButton.

This creates a 3D touch animation for the whole UITableViewCell which looks awesomely beautiful.

Comments