xamarin – .Net MAUI iOS Swipe back navigation not working with regular page navigation flow


I’m currently using standard navigation methods instead of Shell Navigation in my application. I intended to incorporate iOS swipe back navigation, expecting it to function by default. However, it’s not working as anticipated. I came across some threads discussing this issue, such as:

https://learn.microsoft.com/en-us/answers/questions/1143556/how-to-disable-the-swipe-back-in-ios-using-net-mau?sort=votes

I attempted to use this code on the following page to enable swipe back navigation, but unfortunately, it didn’t function as intended:

So my current navigation flow goes like this:

MainPage = new NavigationPage(new Page1());

From Page1:

async void Button_Clicked(System.Object sender, System.EventArgs e)
{
    await Navigation.PushAsync(new Page2());
}

On Page2’s OnAppearing():

protected override void OnAppearing()  
{  
    base.OnAppearing();  
#if IOS  
    UINavigationController vc = (UINavigationController)Platform.GetCurrentUIViewController();//using UIKit, find the UINavigationController  
    vc.InteractivePopGestureRecognizer.Enabled = true;  
#endif  
}

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img