How to compare the types of gestures on iOS?

后端 未结 3 1825
囚心锁ツ
囚心锁ツ 2020-12-19 15:28

I have three different gestures with two different types on one view.

First is a UITapGestureRecognizer and the two others are UILongPressGestureR

3条回答
  •  甜味超标
    2020-12-19 16:16

    I converted the code for Swift 5 to add to this post. It should work as I pulled it off the Apple Documents.

    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer,
       shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer)
        -> Bool { 
        return true
     }
    

    I'm going to try this tomorrow as I've been struggling with UIScrollView and UISwipeGestureRecognizer working together. If I disable Scrolling, then the gesture works, but if I enable Scrolling (what I need), then gesture does not work. I want this feature for hiding and showing the top Navigation Bar and the bottom TabBar when scrolling up and down my scrollview. Then I'm going to try to get it to work with a UICollectionView on the next page in my app. Being new to coding, any suggestions would be appreciated if the above code won't be enough. I'll update this comment if it works or not.

提交回复
热议问题