0

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.

Jitendra Modi
  • 2,344
  • 12
  • 34
nullforlife
  • 1,354
  • 2
  • 18
  • 30

2 Answers2

0

Create a UIView and use a UITapGestureRecognizer with a custom force touch gesture recognizer like this DeepPressGestureRecognizer. Set up the gesture recognizers in a way that the DeepPressGestureRecognizer prevents the UITapGestureRecognizer from recognizing.

Tamás Zahola
  • 9,271
  • 4
  • 34
  • 46
  • I do not think this will look very nice in the 3D touch animation. You will have to layout the button outside from the view and when you force touch the view only the view will get animated. – nullforlife Oct 26 '16 at 13:42
0

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.

nullforlife
  • 1,354
  • 2
  • 18
  • 30