Skip to content

Conversation

Copy link

Copilot AI commented Jan 9, 2026

iOS 26 introduced interactiveContentPopGestureRecognizer for full-screen back navigation. This conflicts with the pager's pan gesture, preventing back navigation when swiping from the first page.

Implementation

  • PagerGestureDelegate.swift: Gesture recognizer delegate implementing shouldRecognizeSimultaneouslyWith

    • Detects back gestures via velocity direction (LTR/RTL aware)
    • Disables pager pan gesture on first page during back swipe
    • KVO observes navigation gesture state to re-enable pager gesture on completion
    • Safe selector-based API access with fallback to interactivePopGestureRecognizer
    • Main queue dispatch for UIKit updates
  • PagerView.swift: Wire up gesture delegate

    • Initialize and assign to collection view's pan gesture recognizer
    • Sync delegate properties (currentPage, scrollEnabled, layoutDirection) via onChange handlers

Behavior

// On first page (currentPage == 0)
// Back gesture (velocity.x > 0 in LTR) → navigation back works
// Forward gesture → pager scrolls normally

// On other pages
// All gestures → pager scrolls normally

Backwards compatible via #available(iOS 26, *) check.

Original prompt

Problem

After upgrading to react-native-screens v4.19.0, the global back swipe gesture doesn't work on iOS 26 when it's on top of a pager view. This is due to iOS 26 introducing a new interactiveContentPopGestureRecognizer that provides a full-screen back gesture, which conflicts with the pager view's pan gesture recognizer.

Referenced issue: #1050
Related issue: #1006
Upstream issue: software-mansion/react-native-screens#3512
Related PR: software-mansion/react-native-screens#3420

Solution

Update the gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: method in the iOS implementation to handle the new iOS 26 interactiveContentPopGestureRecognizer.

The fix should:

  1. Detect when running on iOS 26+
  2. Check if the other gesture recognizer is the navigation controller's interactiveContentPopGestureRecognizer
  3. Determine the swipe direction based on velocity to identify back gestures
  4. When the user is on the first page (currentIndex == 0) and performing a back gesture:
    • Disable the pager's scroll gesture recognizer to allow the navigation back gesture to work
  5. Otherwise, keep the normal pager scrolling behavior enabled

Implementation Details

Add the following logic to the gesture recognizer delegate method in the iOS Paper architecture implementation (RNCPagerView.m):

// 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;
    }
}

This logic should be added before the final return NO; statement in the gesture recognizer method.

Testing

  • Test on iOS 26 with react-native-screens v4.19.0
  • Verify that back swipe gesture works when on the first page of the pager
  • Verify that pager swiping still works normally on other pages
  • Test in both LTR and RTL layouts
  • Verify backwards compatibility with iOS versions < 26

Files to Modify

  • ios/RNCPagerView.m (Paper architecture)
  • Consider if similar changes are needed for Fabric architecture in ios/RNCPagerViewComponentView.mm

References

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

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 changed the title [WIP] Fix back swipe gesture issue on iOS 26 with pager view Fix iOS 26 back gesture conflict with pager pan gesture Jan 9, 2026
Copilot AI requested a review from troZee January 9, 2026 10:02
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