Xamarin iOS 禁用导航滑动效果

Xamarin iOS disable navigation swipe effect

我是移动开发的新手,想问一下没有导航滑动效果的切换页面的方法,只需按下按钮,就会出现所需的页面,而不是旧的页面。我考虑过 TabbedPage,但它不适用于我的 UI。 谢谢

我们可以使用interactivePopGestureRecognizer来禁用导航滑动效果。

只需为 Page 创建渲染器,并在 ViewWillLayoutSubviews 方法中执行。

[assembly: ExportRenderer(typeof(Page), typeof(MyPageRenderer))]
namespace FormsApp.iOS
{
    class MyPageRenderer : PageRenderer
    {
        public override void ViewWillLayoutSubviews()
        {
            base.ViewWillLayoutSubviews();

            if (NavigationController != null)
            {
                NavigationController.InteractivePopGestureRecognizer.Enabled = false;
            }
        }
    }
}

参考

当你按下屏幕时,只需写入动画参数 false

await Navigation.PushAsync (newPage, false);