Handling scroll views with (custom, interactive) view controller presentation and dismissal : <p>I have been experimenting with custom interactive view controller presentation and dismissal (using a combination of <code>UIPresentationController</code>, <code>UIPercentDrivenInteractiveTransition</code>, <code>UIViewControllerAnimatedTransitioning</code>, and <code>UIViewControllerTransitioningDelegate</code>) and have mostly gotten things working well for my needs.</p>

<p>However, there is one common scenario that I've yet to find addressed in any of the tutorials or documentation that I've read, leading me to the following question:</p>

<p>...</p>

<p><strong>What is the proper way of handling custom interactive view controller dismissal, via a pan gesture, when the dismissed view contains a UIScrollView (ie. UITableView, UICollectionView, WKWebView, etc)?</strong></p>

<p>...</p>

<p>Basically, what I'd like is for the following:</p>

<ol>
<li><p>View controllers are interactively dismissible by panning them down. This is common UX in many apps.</p></li>
<li><p>If the dismissed view controller contains a (vertically-scrolling) scroll view, panning down scrolls that view as expected until the user reaches the top, after which the scrolling ceases and the pan-to-dismiss occurs.</p></li>
<li><p>Scroll views should otherwise behave as normal.</p></li>
</ol>

<p>I know that this is <em>technically</em> possible - I've seen it in other apps, such as Overcast and Apple's own Music app - but I've not been able to find the key to coordinating the behavior of my pan gesture with that of the scroll view(s).</p>

<p>Most of my own attempts center on trying to conditionally enable/disable the scrollview (or its associated pan gesture recognizer) based on its <code>contentOffset.y</code> while scrolling and having the view controller dismissal's pan gesture recognizer take over from there, but this has been fraught with problems and I fear that I am overthinking it.</p>

<p>I feel like the secret mostly lies in the following pan gesture recognizer delegate method:</p>

<pre><code>func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -&gt; Bool {
   // ...
}
</code></pre>

<p>I have created a reduced sample project which should demonstrate the scenario more clearly. Any code suggestions are highly welcome!</p>

<p><a href="https://github.com/Darchmare/SlidePanel-iOS" rel="noreferrer">https://github.com/Darchmare/SlidePanel-iOS</a></p>
