ScrollView gesture recognizer eating all touch events

前端 未结 9 819
北恋
北恋 2020-11-27 03:45

I have a UIScrollView to which I added a single tap gesture recognizer to show/hide some UI overlay using:

UITapGestureRecognizer *singleTap = [         


        
9条回答
  •  星月不相逢
    2020-11-27 04:04

    Thanks @zambrey

    Swift 2.2+ Version:

    scrollView.delegate = self
    
    let allowMultipleTouches = UITapGestureRecognizer(target: self, action: #selector(genderPressed))
    allowMultipleTouches.numberOfTapsRequired = 1
    allowMultipleTouches.cancelsTouchesInView = false
    
    scrollView.addGestureRecognizer(allowMultipleTouches)
    

    If your scroll view is in the Storyboard, don't forget to pin the Outlet in the view controller. In this example, scrollView is the Outlet of the UIScrollView.

提交回复
热议问题