1

I have a problem where I have a UIButton in front of UIScrollView, as such:

UIView
|
|- UIScrollView
|
|- UIButton

I want it to be this way so the button is always visible and fixed on the top, but I also want to be able to scroll the UIScrollView through the button if your finger is dragged instead of tapped over the button. I have searched through multiple solutions inside Stack overflow and the closest one is this: UIButton pass-through tap-and-scroll gesture to UIScrollView but none of the solutions posted there works for my case.

Here is the source code for if you want to replicate it exactly as I have: https://github.com/eduasinco/DoubleScrollView

This problem seems to be very common but I have still not founded any straightforward solution.

I have already tried all kinds of things:

  • overriding the hitTest function inside UIButton
  • overriding touchesBegan, touchesMoved, touchesEnded methods
  • overriding next variable to return ScrollView as the next UIResponder
  • setting the isExclusiveTouch method in UIButton
  • changing the isUserInteractionEnabled in every way possible
  • etc, etc, etc...

None of them work, as such, any help will be appreciated :)

ERP
  • 325
  • 2
  • 11

0 Answers0