ScrollView not scrolling when dragging on buttons

前端 未结 5 2015
暖寄归人
暖寄归人 2020-11-29 18:17

I have a scroll view that used to scroll when it didn\'t have buttons all over it. Now it does, and when dragging the mouse (on simulator) nothing happens (i think because t

5条回答
  •  星月不相逢
    2020-11-29 18:59

    I founded this question looking for the swift solution for this problem, I "translated" it like this:

    Swift 5

    class UIButtonScrollView: UIScrollView {
    
        override func touchesShouldCancel(in view: UIView) -> Bool {
            if view.isKind(of: UIButton.self) {
              return true
            }
    
            return super.touchesShouldCancel(in: view)
        }    
    }
    

    hope this could help

提交回复
热议问题