Reputation: 140
Currently i have a class which disables the user from using the backswipe gesture to go back to the previous page on the iOS platform, this code works but the Navigation Side bar still appears when the user does the backswipe gesture, is their a way to disable this feature as well.
My current code stopping backswipe:
using DisableSwipe.iOS;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(ContentPage),
typeof(NoBackSwipeRenderer))]
namespace DisableSwipe.iOS
{
public class NoBackSwipeRenderer : PageRenderer
{
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
if (ViewController != null && ViewController.NavigationController != null)
ViewController.NavigationController.InteractivePopGestureRecognizer.Enabled = false;
}
}
}
Upvotes: 0
Views: 528
Reputation: 8124
You need to set IsGestureEnabled="false"
in you Xaml code of MasterDetailPage like this:
<?xml version="1.0" encoding="utf-8"?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Sample.Views"
x:Class="Sample.Views.MainPage"
IsGestureEnabled="false">
<MasterDetailPage.Master>
<views:MenuPage />
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage>
<x:Arguments>
<views:ItemsPage />
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
</MasterDetailPage>
Upvotes: 1
Reputation: 34118
To disable the swipe gesture on a MasterDetail view you can simply use the IsGestureEnabled
property. See: https://learn.microsoft.com/en-us/dotnet/api/xamarin.forms.masterdetailpage.isgestureenabled?view=xamarin-forms
Upvotes: 0