Hello @Tumi Tladi ,
You mean the swipe to go back to previous view gesture in the navigation, right? If so, you can refer to the example below:
With NavigationPage
Set a NavigationPage
as MainPage
in App
MainPage = new NavigationPage(new MainPage());
Push to NextPage
in MainPage
Navigation.PushAsync(new NextPage());
Disable he swipe back gesture in NextPage
protected override void OnAppearing()
{
base.OnAppearing();
#if IOS
UINavigationController vc = (UINavigationController)Platform.GetCurrentUIViewController();//using UIKit, find the UINavigationController
vc.InteractivePopGestureRecognizer.Enabled = false;
#endif
}
---Update---
With Shell
You can overwrite the CreateShellSectionRenderer
method in ShellRenderer
, and set InteractivePopGestureRecognizer.Enabled = false;
for the ShellSectionRenderer
. Because the InteractivePopGestureRecognizer.Delegate
has been set in the source code of ShellSectionRenderer
, please see the source code here.
And you can use customrenderer with MAUI, see .NET MAUI control customization with handlers - .NET MAUI | Microsoft Learn and Porting Custom Renderers to Handlers in Wiki and refer to the following code:
In MauiProgram
builder.UseMauiApp<App>().ConfigureMauiHandlers((handlers)=>{
#if IOS
handlers.AddHandler(typeof(Shell), typeof(CustomShellRenderer));
#endif
});
CustomShellRenderer
should be under Platform/iOS folder
public class CustomShellRenderer: ShellRenderer
{
public CustomShellRenderer()
{
}
protected override IShellSectionRenderer CreateShellSectionRenderer(ShellSection shellSection)
{
return new CustomSectionRenderer(this);
}
}
public class CustomSectionRenderer : ShellSectionRenderer
{
public CustomSectionRenderer(IShellContext context) : base(context)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
InteractivePopGestureRecognizer.Enabled = false;
}
}
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.