You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[iOS] Swipe-back gesture on root page pops NavigationPage into a blank white screen
Description
On iOS, performing the native swipe-back gesture (interactive pop gesture) while on the root page of a NavigationPage causes the native UINavigationController to pop the root view controller. Since no pages remain in the navigation stack, the app displays a blank white screen.
This issue commonly occurs when initializing the app with a Splash/Initializer page and resetting the stack to MainPage via ../MainPage.
Add a stack count check in ShouldBegin to prevent native popping when ViewControllers.Length <= 1.
publicclassSwipeBackDelegate:UIGestureRecognizerDelegate{protectedMPowerKitNavigationRendererNavRenderer{get;}publicSwipeBackDelegate(MPowerKitNavigationRenderernavRenderer){NavRenderer=navRenderer;}publicoverrideboolShouldBegin(UIGestureRecognizerrecognizer){// Disable gesture when on the root page (stack count <= 1)if(NavRenderer.ViewControllers==null||NavRenderer.ViewControllers.Length<=1){returnfalse;}returnNavRenderer.ShouldPopItem(default,default);}}
Reproducible Example Scenario
1. Setup Initial Route in MauiProgram.cs
publicstaticclassMauiProgram{publicstaticMauiAppCreateMauiApp(){varbuilder=MauiApp.CreateBuilder();builder.UseMauiApp<App>().UseMPowerKitNavigation(onAppStart:async(navigationService)=>{// Start app with NavigationPage / AppInitializerPageawaitnavigationService.NavigateAsync($"NavigationPage/{nameof(AppInitializerPage)}");});returnbuilder.Build();}}
2. Reset Stack to MainPage from Splash (AppInitializerViewModel.cs)
publicclassAppInitializerViewModel:BindableBase{privatereadonlyINavigationService_navigationService;publicAppInitializerViewModel(INavigationServicenavigationService){_navigationService=navigationService;}publicasyncTaskOnAppInitializedAsync(){// Perform app checks, API calls, etc.awaitTask.Delay(1000);// Replace AppInitializerPage with MainPage in the NavigationPage stackvarresult=await_navigationService.NavigateAsync($"../{nameof(MainPage)}");}}
3. Reproducing the Issue on MainPage
The app successfully navigates from AppInitializerPage to MainPage.
On MainPage (now the root page in NavigationPage), swipe right from the left edge of the screen (iOS Interactive Pop Gesture).
Actual Result:SwipeBackDelegate.ShouldBegin returns true, popping MainPage and leaving the UINavigationController empty (blank white screen).
Expected Result: The swipe gesture should be ignored because MainPage is the root page (ViewControllers.Length <= 1).
Title:
[iOS] Swipe-back gesture on root page pops NavigationPage into a blank white screenDescription
On iOS, performing the native swipe-back gesture (interactive pop gesture) while on the root page of a
NavigationPagecauses the nativeUINavigationControllerto pop the root view controller. Since no pages remain in the navigation stack, the app displays a blank white screen.This issue commonly occurs when initializing the app with a Splash/Initializer page and resetting the stack to
MainPagevia../MainPage.Code Changes Required
File:
MPowerKit.Navigation/Platforms/iOS/Renderers/MPowerKitNavigationRenderer.csTarget Class:
SwipeBackDelegateinsideMPowerKitNavigationRendererProposed Fix:
Add a stack count check in
ShouldBeginto prevent native popping whenViewControllers.Length <= 1.Reproducible Example Scenario
1. Setup Initial Route in
MauiProgram.cs2. Reset Stack to
MainPagefrom Splash (AppInitializerViewModel.cs)3. Reproducing the Issue on
MainPageAppInitializerPagetoMainPage.MainPage(now the root page inNavigationPage), swipe right from the left edge of the screen (iOS Interactive Pop Gesture).SwipeBackDelegate.ShouldBeginreturnstrue, poppingMainPageand leaving theUINavigationControllerempty (blank white screen).MainPageis the root page (ViewControllers.Length <= 1).video_2026-08-24_11-04-09.mp4