title: make pan gesture recognizer only respond when swiping down AND at the top of a tableview
body: <p>I am trying to dismiss the current viewcontroller when the user swipes down at the top of the tableView. Since the tableview takes up the whole screen, my gesture and the <code>tableView</code>'s gesture conflicts.</p>
  
  <p>I thought about making my <code>UIPanGestureRecognizer</code> only respond if the user has not scrolled the tableview (<code>tableView.contentOffset.y == 0.0</code>) and the direction of the swipe is downwards. However, I have not succeeded implementing this.</p>
  
  <p>This is my code:</p>
  
  <pre><code>var tableGesture: UIPanGestureRecognizer?
  var oPosition: CGPoint?
  var currentPosition: CGPoint?
  @IBOutlet weak var table: UITableView!
  
  override func viewDidLoad() {
      super.viewDidLoad()
      table.delegate = self
      table.dataSource = self
  
      tableGesture = UIPanGestureRecognizer(target: self, action: #selector(tableGesture(_:)))
      table.addGestureRecognizer(tableGesture!)
  }
  
  override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -&gt; Bool {
      let translation = tableGesture?.translation(in: table)
      return translation!.y &gt; 0 &amp;&amp; table.contentOffset.y == 0.0
  }
  </code></pre>
  
  <p>I have looked around at similar questions but none of the answers worked for me.</p>