Xamarin 表单:主详细信息页面:如何禁用滑动手势以在 iOS 上加载菜单

Xamarin Form : Master Detail Page : How to disable swipe gesture to load the menu on iOS

我需要屏幕在上面画东西。由于我在同一屏幕上有一个Master Detail Page,所以每当我在打开菜单的方向上绘制时,菜单会在我绘制的同时滑动打开。

有没有办法阻止它滑动打开,但仍然可以点击菜单按钮打开它。

我找到了解决方案:

#if __IOS__
    IsGestureEnabled = false
#endif

设置 Is GestureEnabled 为 false 将停止滑动打开菜单。只能为 iOS 设置此值。如果我设置为 android,菜单按钮在单击时不会打开菜单。

为此,您需要编写 IsPresented = true 以及

#if __IOS__
IsGestureEnabled = false
#endif

MasterDetailPage 上添加:

protected override void OnAppearing()
{
    base.OnAppearing();

    if (Device.RuntimePlatform == Device.iOS)
    {
        IsGestureEnabled = false;
    }
}