Conflit between the LongPressGesture of a button inside a UITableViewCell and the scroll of the UITableView

Hello Dear Apple Developers,

I have a UITableView which contains the UITableViewCell with a button inside.

When I long press the area out of the button and try to scroll, the tableView scroll well.

But when I long press the button and try to scroll, that block my scroll gesture. And I didn't add a longPressGesture to this button. I also tried to check the button.gestureRecognizers, there is nothing.

Could you please how to solve this problem, thank you very much!

Replies

Why do you want user to be able to longpress the button ? That's not very natural. When user taps button, he/she wants immediate response, not waiting for the system to detect a potential longpress.

But if you want, you should add a gesture to the UIButton: https://stackoverflow.com/questions/30859203/uibutton-with-single-press-and-long-press-events-swift

And manage it to scroll the view.

  • Hello Claude,

    Thank you for your responses, yes, I don't want user to be able to longpress the button, this is my target. But the longpress gesture is native, and this is the user who complain with it. You can try with this scenario, you create a table view and add some tableViewCells which contain a button, and you try to hold your finger on a button within few seconds, than try to scroll the tableview, the scroll doesn't work any more. So I think that the press-pan action has some conflicts

Add a Comment