3

I'm trying to reproduce the buttom sheet in Apple's iOS 10 Maps app. Most of it is working. I've been looking at this SO post and Pulley on GitHub, but none of them solves my issue.

When the sheets is fully opened, it is possible to scroll the content of the sheet as a UITableView, but when the user tries to scroll down (where the UITableView's contentOffset would be negative), the gesture is dragging in the sheet instead of the UITableView. The gesture seamlessly changes from dragging the UITableView to dragging the sheet.

It is possiple disable the scrolling of the UITableView in the gesture delegate's shouldRecognizeSimultaneouslyWith, but this is only called when a gesture begins.

I can't control the panGestureRecognizer of the UITableView, so I can't just capture the gesture and determine what view it should move.

How can I change what UIGestureRecognizer should recognize touches, in the middle of a gesture?

screenshot of Apple's iOS 10 Maps app

Community
  • 1
  • 1
Wiingaard
  • 4,150
  • 4
  • 35
  • 67

1 Answers1

0

Try

override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
    if gestureRecognizer == myCustomPanGesture {
        return self.tableView.contentOffset == 0
    }
    return true
}
Sean Lintern
  • 3,103
  • 22
  • 28
  • This causes both the tableview and the sheet to be scroll as the same this. While the sheet is being dragged down, is the `UITableView`s `contentOffset`'s growing. This also doesn't solve; if the gesture starts dragging at a positive `contentOffset`, the gesture wount change to dragging the sheet when the `contentOffset` reaches zero. – Wiingaard Apr 26 '17 at 13:19
  • hmm it may be you have to create an invisible view with a pan on and designate where the translation goes. – Sean Lintern Apr 26 '17 at 13:31
  • But then I would loose the scrolling effect of the `UITableView` when you give it a swipe, and it's running free and it gradually decreases velocity. Right? – Wiingaard Apr 26 '17 at 13:43
  • yeah essentially unless you recreated that yourself by saving pan velocity and overriding targetContentOffset and returning a value based on the velocity but it would never be the same i expect – Sean Lintern Apr 26 '17 at 13:45