Swipe right in iOS 26

I have a screen with an edge to edge canvas that shows a photograph. The user can pinch the photo to zoom in or out and can tap and drag around the photo to pan around the photo. This works fine in previous versions of iOS but in iOS 26 tapping and dragging on the photo anywhere in about the left two thirds of the Canvas now causes a swipe right to return to the previous screen (even with UI Compatability mode turned on). Is there any way to disable this behavior or modify it so that the user can tap and drag the photo to pan it rather than returning to the previous screen?

Jade’s answer (after getting it wrong twice with one hard crash):

Private Sub DisableSwipeBackGesture()
  #If TargetIOS Then
    Declare Function navigationController Lib "UIKit" Selector "navigationController" (viewController As Ptr) As Ptr
    Declare Function interactivePopGestureRecognizer Lib "UIKit" Selector "interactivePopGestureRecognizer" (navController As Ptr) As Ptr
    Declare Function interactiveContentPopGestureRecognizer Lib "UIKit" Selector "interactiveContentPopGestureRecognizer" (navController As Ptr) As Ptr
    Declare Sub setEnabled Lib "UIKit" Selector "setEnabled:" (gestureRecognizer As Ptr, enabled As Boolean)
    
    ' Get the view controller handle directly from the iOSScreen
    Var currentVC As Ptr = Me.ViewControllerHandle
    If currentVC <> Nil Then
      Var navController As Ptr = navigationController(currentVC)
      If navController <> Nil Then
        ' Disable edge swipe gesture (pre-iOS 26)
        Var edgeGesture As Ptr = interactivePopGestureRecognizer(navController)
        If edgeGesture <> Nil Then
          setEnabled(edgeGesture, False)
        End If
        
        ' Disable content swipe gesture (iOS 26+)
        Var contentGesture As Ptr = interactiveContentPopGestureRecognizer(navController)
        If contentGesture <> Nil Then
          setEnabled(contentGesture, False)
        End If
      End If
    End If
  #EndIf
End Sub

and to re-enable:

Private Sub EnableSwipeBackGesture()
  #If TargetIOS Then
    Declare Function navigationController Lib "UIKit" Selector "navigationController" (viewController As Ptr) As Ptr
    Declare Function interactivePopGestureRecognizer Lib "UIKit" Selector "interactivePopGestureRecognizer" (navController As Ptr) As Ptr
    Declare Function interactiveContentPopGestureRecognizer Lib "UIKit" Selector "interactiveContentPopGestureRecognizer" (navController As Ptr) As Ptr
    Declare Sub setEnabled Lib "UIKit" Selector "setEnabled:" (gestureRecognizer As Ptr, enabled As Boolean)
    
    ' Get the view controller handle directly from the iOSScreen
    Var currentVC As Ptr = Me.ViewControllerHandle
    If currentVC <> Nil Then
      Var navController As Ptr = navigationController(currentVC)
      If navController <> Nil Then
        ' Enable edge swipe gesture (pre-iOS 26)
        Var edgeGesture As Ptr = interactivePopGestureRecognizer(navController)
        If edgeGesture <> Nil Then
          setEnabled(edgeGesture, True)
        End If
        
        ' Enable content swipe gesture (iOS 26+)
        Var contentGesture As Ptr = interactiveContentPopGestureRecognizer(navController)
        If contentGesture <> Nil Then
          setEnabled(contentGesture, True)
        End If
      End If
    End If
  #EndIf
End Sub

It works and does what I need. Curious to know what the Declares gurus on the Forum think of this.

interactiveContentPopGestureRecognizer will crash your app if the device isn’t running iOS26

You should wrap that call in a system.version check for iOS 26.

3 Likes

Thanks, Jeremie! Very helpful and fundamental.