Skip to content

Conversation

Copy link

Copilot AI commented Jan 9, 2026

iOS 18.2 introduced interactiveContentPopGestureRecognizer, a full-screen back gesture that conflicts with PagerView's pan gesture, preventing navigation back when swiping from the first page.

Changes

  • PagerScrollDelegate: Implement UIGestureRecognizerDelegate to handle simultaneous gesture recognition

    • Detect back gestures via pan velocity and layout direction (LTR/RTL aware)
    • Disable collection view pan gesture when on first page during back gesture
    • Re-enable pan gesture after scroll completes
  • PagerView: Wire gesture recognizer delegate and sync state

    • Set pan gesture delegate on introspection
    • Track currentPage, layoutDirection, scrollEnabled in delegate

Implementation

func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, 
                      shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
  if #available(iOS 18.2, *) {
    // Check for interactiveContentPopGestureRecognizer via KVC (private API)
    let velocity = panGestureRecognizer.velocity(in: collectionView)
    let isBackGesture = (isLTR && velocity.x > 0) || (!isLTR && velocity.x < 0)
    
    if currentPage == 0 && isBackGesture {
      collectionView.panGestureRecognizer.isEnabled = false
    }
    return true
  }
  return false
}

Relies on runtime checks for the undocumented interactiveContentPopGestureRecognizer API to ensure forward compatibility.

Original prompt

Problem

After upgrading to react-native-screens v4.19.0, the global back swipe gesture does not work when performed over a pager view on iOS 26. This is due to iOS 26 introducing a new full-screen back gesture recognizer called interactiveContentPopGestureRecognizer which conflicts with the pager view's gesture handling.

Related Issues:

Environment:

  • iOS 26
  • react-native-screens v4.19.0
  • All versions of react-native-pager-view (tested 6.8.0, 6.8.1, 8.0.0)

Reproducible Demo:
https://github.com/mozzius/pagerswipe-repro

Solution

Update the gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: method in ios/RNCPagerView.m to handle the new iOS 26 interactiveContentPopGestureRecognizer.

The fix should:

  1. Check for iOS 26+ availability
  2. Detect when the gesture recognizer is the new interactiveContentPopGestureRecognizer
  3. Determine if the user is performing a back gesture based on:
    • Pan gesture velocity direction
    • Layout direction (LTR/RTL)
  4. If the user is on the first page (currentIndex == 0) and performing a back gesture:
    • Disable the scroll view's pan gesture recognizer to allow the navigation back gesture to work
  5. Otherwise:
    • Keep the scroll view's pan gesture recognizer enabled based on the scrollEnabled property
  6. Return YES to allow simultaneous recognition

Implementation Details

Add the following code to the gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: method after the existing iOS 13+ back gesture handling and before the final return NO:

// iOS 26+ full-screen back gesture (interactiveContentPopGestureRecognizer)
if (@available(iOS 26, *)) {
    if (gestureRecognizer == self.panGestureRecognizer &&
        otherGestureRecognizer == self.reactViewController.navigationController.interactiveContentPopGestureRecognizer) {
        UIPanGestureRecognizer* panGestureRecognizer = (UIPanGestureRecognizer*) gestureRecognizer;
        CGPoint velocity = [panGestureRecognizer velocityInView:self];
        BOOL isLTR = [self isLtrLayout];
        BOOL isBackGesture = (isLTR && velocity.x > 0) || (!isLTR && velocity.x < 0);

        if (self.currentIndex == 0 && isBackGesture) {
            self.scrollView.panGestureRecognizer.enabled = false;
        } else {
            self.scrollView.panGestureRecognizer.enabled = self.scrollEnabled;
        }

        return YES;
    }
}

Note: This fix is based on the working patch provided by @mozzius in issue #1050.

Testing

After applying this fix:

  1. The global back swipe gesture should work when on the first page of the pager view
  2. The pager view should still be swipeable between pages normally
  3. The fix should work with both LTR and RTL layouts
  4. The fix should not affect iOS versions below 26

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 9, 2026 09:57
…nizer

- Implement UIGestureRecognizerDelegate in PagerScrollDelegate
- Add gesture recognizer handling for iOS 18.2+ (iOS 26)
- Detect back gestures based on velocity and layout direction (LTR/RTL)
- Disable pan gesture when on first page performing back gesture
- Re-enable pan gesture after dragging/decelerating ends
- Update delegate properties when props change

Co-authored-by: troZee <[email protected]>
Copilot AI changed the title [WIP] Fix back swipe gesture conflict with pager view on iOS 26 Fix iOS 18.2+ back gesture conflict with PagerView Jan 9, 2026
Copilot AI requested a review from troZee January 9, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants